【发布时间】: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: truewhich skips the install step。 -
哦,现在我明白你的意思了。甚至不知道安装步骤存在,我以为您在谈论我的
mvn install命令。所以感谢您的 cmets,他们可能会解决这个问题(现在正在解决这个问题)。你把它作为答案发布吗?如果没有,我以后会自己写。
标签: java maven travis-ci cobertura maven-cobertura-plugin