How to skip the test when maven builds

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:

  1. skipTests, such as:
1
mvn -DskipTests build
  1. 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.

本文标题:How to skip the test when maven builds

文章作者:Morning Star

发布时间:2022年01月24日 - 19:01

最后更新:2022年01月25日 - 15:01

原始链接:https://www.mls-tech.info/java/howto-skip-test-maven-build/

许可协议: 署名-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。