2

I have Cobertura setup as following in my pom:

...
<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>
...

If I run:

mvn clean cobertura:cobertura

Everything passes fine. If I run:

mvn clean install

Everything passes fine. However, if I run:

mvn clean cobertura:cobertura install

The build fails during the install saying that my code coverage is 0% i.e:

[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]

Any ideas why?

James
  • 1,237
  • 4
  • 22
  • 43

1 Answers1

0

When you run:

mvn cobertura:cobertura

It just generated the reports.

when you run

mvn install

It runs all the plugins you have set up there, including configurations you have set up which have the line and branch checks

Bojan Petkovic
  • 2,406
  • 15
  • 26