"-Dmaven.test.skip.exec"和"-Dmaven.test.skip=true"以及"-DskipTests"有什么区别?(涉及IT技术)

45
我不确定maven指令 -Dmaven.test.skip.exec-Dmaven.test.skip=true -DskipTests 之间的区别。两者都似乎可以阻止测试周期。

可能是重复的问题:https://dev59.com/WWoy5IYBdhLWcg3wPLr0#14779004 - Software Engineer
这并不是那个问题的重复,那个问题更多的是“我尝试了所有这些方法,但它们都不起作用”... :) - rogerdpack
3个回答

69

"maven.test.skip.exec=true"表示编译测试代码但不执行。

"maven.test.skip=true"表示不会编译或执行测试代码。

"-DskipTests"与"maven.test.skip.exec=true"是相同的,都表示跳过测试代码的执行。


20

系统属性 -Dmaven.test.skip=true 的作用如下:

因为 maven.test.skip 禁用了测试运行和编译测试。

系统属性 -Dmaven.test.skip.exec 已被弃用,应该使用 -DskipTests=true

将其设置为“true”以跳过运行测试,但仍要编译测试。


4
请参考以下链接: http://maven.apache.org/surefire/maven-surefire-plugin/examples/skipping-test.html 提取内容:

Skipping Tests

To skip running the tests for a particular project, set the skipTests property to true.

<project>
  [...]
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.18.1</version>
        <configuration>
          <skipTests>true</skipTests>
        </configuration>
      </plugin>
    </plugins>
  </build>
  [...]
</project>

You can also skip the tests via the command line by executing the following command:

mvn install -DskipTests

If you absolutely must, you can also use the maven.test.skip property to skip compiling the tests. maven.test.skip is honored by Surefire, Failsafe and the Compiler Plugin.

mvn install -Dmaven.test.skip=true

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接