noMAD
noMAD

Reputation: 7844

Cobertura not recognizing tests

I have added the dependency but for some reason Cobertura decided against loading any of my test classes from src/test/. It just loads the classes from src/java/ and hence doesn't show the code coverage or anything. I checked the packages (all the classes, tests are in the same package) and the dependencies. Any help, pointers??

Here is my cobertura dependency plugin under maven-shade configurations:

<cobertura.version>2.5.2</cobertura.version>


<plugin>
   <groupId>org.codehaus.mojo</groupId>
   <artifactId>cobertura-maven-plugin</artifactId>
   <version>${cobertura.version}</version>
</plugin>

I also have the same thing under maven-site plugin

Upvotes: 0

Views: 2492

Answers (1)

Allen Parslow
Allen Parslow

Reputation: 209

Your structure is not mavenized, unless you have overridden the default maven configuration. It should be src/main/java and src/test/java.

Also check that you have followed surefire plugin (the plugin that runs tests) conventions (e.g. *Test.java) or have overridden configuration see surefire inclusion-exclusion for all of the default patterns accepted.

Verify that mvn clean test has run your tests, i.e. look for "Tests run: 52, Failures: 0, Errors: 1, Skipped: 0" in the output.

Verify that mvn cobertura:cobertura also runs your tests and produces a index.html in /target/site/cobertura/ (open this file to ensure that it includes all of your classes). Also check for the presence of /target/cobertura/cobertura.ser.

Upvotes: 3

Related Questions