javamaventravis-cicoberturamaven-cobertura-plugin

Cobertura Checks Fail on Travis CI


In my Maven build, I use Cobertura to check that there is a certain minimal coverage:

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

When running mvn install, this works fine. However, in Travis CI, the build fails because Travis first runs mvn install -DskipTests=true to get the dependencies. Obviously, when tests are skipped, there is no coverage, and therefore the whole build fails:

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

Can I somehow configure Cobertura to skip the check if tests are skipped? Or is there any other solution, maybe on the Travis side?


Here is my .travis.yml file:

language: java

jdk:
  - openjdk6
  - openjdk7
  - oraclejdk7
  - oraclejdk8

script: "mvn install"

Solution

  • You can turn that of by using: install: true which skips the install step.