在我的 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"
最佳答案
您可以使用以下命令将其关闭: install: true
which skips the install step .
关于java - Cobertura 检查 Travis CI 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35842780/