【问题标题】:Cobertura check fails when maven run with Cobertura report and install goals当 maven 运行 Cobertura 报告并安装目标时,Cobertura 检查失败
【发布时间】:2014-12-18 00:40:40
【问题描述】:

我的 pom 中有如下 Cobertura 设置:

...
<build>
...
<plugins>
...
<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>cobertura-maven-plugin</artifactId>
    <version>${cobertura-maven-plugin.version}</version>
    <configuration>
        <formats>
            <format>html</format>
        </formats>
        <outputDirectory>${project.build.directory}</outputDirectory>
        <check>
            <haltOnFailure>${testsAreRun}</haltOnFailure>
            <totalBranchRate>27</totalBranchRate>
            <totalLineRate>88</totalLineRate>
        </check>
        <instrumentation>
            <ignoreTrivial>true</ignoreTrivial>
            <excludes>
                <exclude>something/app/**/*.class</exclude>
                <exclude>something/config/**/*.class</exclude>
            </excludes>
        </instrumentation>
    </configuration>
    <executions>
        <execution>
            <phase>verify</phase>
            <goals>
                <goal>clean</goal>
                <!--<goal>cobertura</goal>-->
                <goal>check</goal>
            </goals>
        </execution>
    </executions>
</plugin>
...
<plugins>
...
<build>
...

如果我跑:

mvn clean cobertura:cobertura

一切顺利。如果我跑:

mvn clean install

一切顺利。但是,如果我运行:

mvn clean cobertura:cobertura install

在安装过程中构建失败,说我的代码覆盖率为 0%,即:

[ERROR] Oct 22, 2014 3:03:59 PM net.sourceforge.cobertura.coveragedata.CoverageDataFileHandler loadCoverageData
INFO: Cobertura: Loaded information on 8 classes.
Project failed check. Total branch coverage rate of 0.0% is below 27.0%
Project failed check. Total line coverage rate of 0.0% is below 88.0%

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 15.839 s
[INFO] Finished at: 2014-10-22T15:03:59+01:00
[INFO] Final Memory: 38M/469M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:cobertura-maven-plugin:2.6:check (default) on project something: Coverage check failed. See messages above. -> [Help 1]

有什么想法吗?

【问题讨论】:

    标签: maven cobertura maven-cobertura-plugin


    【解决方案1】:

    当你运行时:

    mvn cobertura:cobertura

    它只是生成了报告。

    当你运行时

    mvn 安装

    它运行您在那里设置的所有插件,包括您设置的具有线路和分支检查的配置

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-16
      • 2014-06-30
      • 2014-12-01
      • 1970-01-01
      相关资源
      最近更新 更多