Skip Unit Test Cases - Maven

1. maven.test.skip=true

1.1 To skip unit tests, uses this argument -Dmaven.test.skip=true
Terminal
$ mvn package -Dmaven.test.skip=true

1.2 Or defined in pom.xml and run the package command normally.
pom.xml
    <properties>
        <maven.test.skip>true</maven.test.skip>
    </properties>

$ mvn package
#no test

2. skipTests

2.1 Alternatively, use this surefire -DskipTests
Terminal
$ mvn package -DskipTests

2.2 Or this.
pom.xml
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.19.1</version>
    <configuration>
        <skipTests>true</skipTests>
    </configuration>
</plugin> 

3. maven.test.skip vs skipTests

The core difference :
  1. maven.test.skip is a feature of Maven itself, skip compile tests, skip run test, just ignore any test processes.
  2. skipTests is a feature of surefire plugin, compile the tests but skip running it.
Normally, I prefer maven.test.skip

Comments

Popular posts from this blog

gsutil Vs Storage Transfer Service Vs Transfer Appliance

SQL basic interview question