How do I skip the tests during the default lifecycle?
Author: Deron Eriksson
Description: This maven tutorial describes how to skip the tests during the default lifecycle.
Tutorial created using:
Windows Vista || JDK 1.6.0_04 || Eclipse Web Tools Platform 2.0.1 (Eclipse 3.3.1)
On occasion, you may want to skip the tests during the mavenSW default lifecycle, although in general this is not a good practice. One way to do this is to include -DskipTests in the maven command. Here is the console output of a 'mvn package' command, where tests are not skipped. Console output of 'mvn package' on 'aproject' project[INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] Building aproject [INFO] task-segment: [package] [INFO] ------------------------------------------------------------------------ [INFO] [resources:resources] [INFO] Using default encoding to copy filtered resources. [INFO] [compiler:compile] [INFO] Nothing to compile - all classes are up to date [INFO] [resources:testResources] [INFO] Using default encoding to copy filtered resources. [INFO] [compiler:testCompile] [INFO] Nothing to compile - all classes are up to date [INFO] [surefire:test] [INFO] Surefire report directory: C:\dev\workspace\aproject\target\surefire-reports ------------------------------------------------------- T E S T S ------------------------------------------------------- Running com.maventest.AppTest Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.039 sec Results : Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 [INFO] [jar:jar] [INFO] Building jar: C:\dev\workspace\aproject\target\aproject-1.0-SNAPSHOT.jar [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESSFUL [INFO] ------------------------------------------------------------------------ [INFO] Total time: 2 seconds [INFO] Finished at: Tue Feb 19 16:24:26 PST 2008 [INFO] Final Memory: 5M/11M [INFO] ------------------------------------------------------------------------ Now, let's turn off the tests. Here is the console output of a 'mvn -DskipTests package' command, where tests are skipped. Console output of 'mvn -DskipTests package' on 'aproject' project[INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] Building aproject [INFO] task-segment: [package] [INFO] ------------------------------------------------------------------------ [INFO] [resources:resources] [INFO] Using default encoding to copy filtered resources. [INFO] [compiler:compile] [INFO] Nothing to compile - all classes are up to date [INFO] [resources:testResources] [INFO] Using default encoding to copy filtered resources. [INFO] [compiler:testCompile] [INFO] Nothing to compile - all classes are up to date [INFO] [surefire:test] [INFO] Tests are skipped. [INFO] [jar:jar] [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESSFUL [INFO] ------------------------------------------------------------------------ [INFO] Total time: 1 second [INFO] Finished at: Tue Feb 19 16:24:34 PST 2008 [INFO] Final Memory: 5M/10M [INFO] ------------------------------------------------------------------------ We can also turn off tests via the pom.xml file. Fragment of pom.xml that turns off tests... <build> <plugins> <plugin> <artifactId>maven-surefire-plugin</artifactId> <configuration> <skipTests>true</skipTests> </configuration> </plugin> </plugins> </build> ... Related Tutorials: |