【问题标题】:Cobertura Checks Fail on Travis CICobertura 检查 Travis CI 失败
【发布时间】:2016-03-07 11:40:34
【问题描述】:

在我的 Maven 构建中,我使用 Cobertura 来检查是否存在一定的最小覆盖范围:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>cobertura-maven-plugin</artifactId>
    <version>2.5.2</version>
    <configuration>
        <check>
            <branchRate>100</branchRate>
        </check>
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>cobertura</goal>
                <goal>check</goal>
            </goals>
        </execution>
    </executions>
</plugin>

当运行mvn install 时,它运行良好。但是,在 Travis CI 中,构建失败是因为 Travis first runs mvn install -DskipTests=true 获取依赖项。显然,当跳过测试时,没有覆盖,因此整个构建失败:

[ERROR] ch.trick17.betterchecks.fluent.StringCheck failed check. Branch coverage rate of 0.0% is below 100.0%
...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
...
[ERROR] Failed to execute goal org.codehaus.mojo:cobertura-maven-plugin:2.5.2:check (default) on project better-checks-core: Coverage check failed. See messages above. -> [Help 1]

我能否以某种方式将 Cobertura 配置为跳过检查是否跳过测试?还是有其他解决方案,也许是在 Travis 方面?


这是我的.travis.yml 文件:

language: java

jdk:
  - openjdk6
  - openjdk7
  - oraclejdk7
  - oraclejdk8

script: "mvn install"

【问题讨论】:

  • 你在 Travis 上运行install 步骤是什么...在大多数情况下它是不需要的。所以只需要脚本步骤。
  • @khmarbaise 感谢您的评论,但我认为问题与指定的脚本无关(请参阅更新的答案),因为 Travis 无论如何都会运行 mvn install -DskipTests=true
  • 您可以使用以下方式关闭它:install: true which skips the install step
  • 哦,现在我明白你的意思了。甚至不知道安装步骤存在,我以为您在谈论我的 mvn install 命令。所以感谢您的 cmets,他们可能会解决这个问题(现在正在解决这个问题)。你把它作为答案发布吗?如果没有,我以后会自己写。

标签: java maven travis-ci cobertura maven-cobertura-plugin


【解决方案1】:

您可以使用:install: truewhich skips the install step 来关闭它。

【讨论】:

    【解决方案2】:

    作为 kmarbaise 答案的替代方案,您可以替换自定义它而不是完全关闭安装步骤,以便它 skips the Cobertura check

    install: mvn install -DskipTests=true -Dmaven.javadoc.skip=true -Dcobertura.skip=true -B -V
    

    这样,您的实际构建脚本的输出将不会被下载依赖项和 Maven 插件的输出弄乱。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-11-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多