Maven is the most popular project building tool for the Java platform, and the test-driven development (TDD) is also the development method chosen by many teams in Java platform project development. But when building a project with maven, if for some reason, we want not to perform unit tests in this build. So what to do?
Solutions
There are two command-line arguments that help us prevent maven from performing unit tests while building the project:
- skipTests, such as:
1 | mvn -DskipTests build |
- maven.test.skip=true, such as:
1 | mvn -Dmaven.test.skip=true build |
The difference between the two parameters
-DskipTests,The test case is not executed, but the test case class is compiled to generate the corresponding class file under target/test-classes.
-Dmaven.test.skip=true,Test cases are not executed, and test case classes are not compiled.