The Maven Cookbook

7.7. Skipping Unit Tests

7.7. Skipping Unit Tests

7.7.1. Task

You need to skip unit tests in a Maven build.

7.7.2. Action

To skip unit tests in a Maven build, pass a value of true to the parameter maven.test.skip to Maven on the command line.

$ mvn install -Dmaven.test.skip=true
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building testng-groups
[INFO]    task-segment: [install]
[INFO] ------------------------------------------------------------------------
[INFO] [resources:resources {execution: default-resources}]
[WARNING] Using platform encoding (MacRoman actually) to copy filtered 
resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Nothing to compile - all classes are up to date
[INFO] [resources:testResources {execution: default-testResources}]
[WARNING] Using platform encoding (MacRoman actually) to copy filtered 
resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO] [compiler:testCompile {execution: default-testCompile}]
[INFO] Not compiling test sources
[INFO] [surefire:test {execution: default-test}]
[INFO] Tests are skipped.
[INFO] [jar:jar {execution: default-jar}]
[INFO] Building jar: /Users/Tim/Library/Code/sonatype/maven-cookbook/
mcookbook-examples/unit/testng-groups/target/testng-groups-1.0-SNAPSHOT.jar
[INFO] [install:install {execution: default-install}]
[INFO] Installing /Users/Tim/Library/Code/sonatype/maven-cookbook/
mcookbook-examples/unit/testng-groups/target/testng-groups-1.0-SNAPSHOT.jar 
to /Users/Tim/.m2/repository/org/sonatype/mcookbook/testng-groups/
1.0-SNAPSHOT/testng-groups-1.0-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4 seconds
[INFO] Finished at: Thu Nov 26 12:32:14 CST 2009
[INFO] Final Memory: 15M/80M
[INFO] ------------------------------------------------------------------------

7.7.3. Detail

If you need to configure a Maven build to skip tests, you would add the following Maven Surefire configuration.

     <plugin>
       <groupId>org.apache.maven.plugins</groupId>
       <artifactId>maven-surefire-plugin</artifactId>
       <configuration>
         <skip>true</skip>
       </configuration>
      </plugin>