【问题标题】:Skip test case execution in maven doesn't even compile Test cases在 maven 中跳过测试用例执行甚至不编译测试用例
【发布时间】:2014-06-16 08:15:29
【问题描述】:

使用 Maven 构建配置,我们可以将其配置为在构建源文件时跳过测试执行。在 Eclipse 中,我们可以选中标记为“Skip Test”的复选框,并且可以从命令行使用

mvn clean install -Dmaven.test.skip=true

跳过测试甚至不编译单元测试源代码。

有什么方法可以配置 maven 使其编译单元测试类但不执行它?

【问题讨论】:

标签: java eclipse unit-testing maven


【解决方案1】:

当你指定 -DskipTests 时它会编译测试类,它只是跳过测试的执行

maven.test.skip 停止编译测试类


文档

【讨论】:

    【解决方案2】:

    -Dmaven.test.skip=true 甚至不编译单元测试。如果您想构建它们但不运行它们,您可以使用skipTests 标志:

    mvn clean install -DskipTests=true
    

    或其简写版本:

    mvn clean install -DskipTests
    

    有关完整详细信息,另请参阅 skipping tests 上的 maven 文档。

    【讨论】:

      【解决方案3】:
      <properties>
          <maven.test.skip>true</maven.test.skip>
      </properties>
      

      将此代码添加到您的 pom.xml 文件中。

      【讨论】:

        【解决方案4】:

        运行mvn install 时,您可以:

        • 跳过测试执行和编译:-Dmaven.test.skip=true
        • 只跳过测试执行但编译它们:-DskipTests=true

        请注意,当未明确指定时,这些属性默认为 false

        【讨论】:

        • 似乎@JigarJoshi 提到的相反方法对我有用。
        • 过去是复制问题,现在已修复 :)
        猜你喜欢
        • 1970-01-01
        • 2011-07-21
        • 1970-01-01
        • 1970-01-01
        • 2018-12-07
        • 2011-08-12
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多