I have a project with several tests and Cobertura Maven Plugin. All works fine but one Class with its test are driving me crazy.
This is the cobertura report with 83% of line coverage:
And this is the basic test:
import static org.junit.Assert.assertEquals;
import org.junit.Test;
public class TimeHelperTest {
@Test
public void elapsedMillisToHumanExpression() throws Exception {
assertEquals("0 min 3 seg 600 millis",
TimeHelper.elapsedMillisToHumanExpression(1000000000l, 1000003600l));
}
}
Question
- What means 0 at the left of class name in cobertura report?
Other classes show numbers > 0 and are green.
Environment
- java 8
- ubuntu
- eclipse
- pom.xml
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.7</version>
<configuration>
<check>
<haltOnFailure>true</haltOnFailure>
<branchRate>90</branchRate>
<lineRate>90</lineRate>
<totalBranchRate>90</totalBranchRate>
<totalLineRate>90</totalLineRate>
<packageLineRate>90</packageLineRate>
<packageBranchRate>90</packageBranchRate>
</check>
<formats>
<format>html</format>
</formats>
</configuration>
<executions>
<execution>
<id>cobertura-clean-and-check</id>
<phase>prepare-package</phase>
<goals>
<goal>clean</goal>
<goal>cobertura</goal>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Attempts
I tried with several changes in my @Test but report does not change !!
- use
extends TestCase
- use
@RunWith
- use maven-surefire-plugin including **/*Test.java
- remove thresholds in pom.xml
Research
- Cobertura code coverage is 0% when using Maven 3
- https://github.com/cobertura/cobertura/issues/136
- http://cobertura.996293.n3.nabble.com/Cobertura-shows-zero-code-coverage-despite-all-tests-running-td2829.html
- This talk about base path of test for ant projects but I can't use it in my maven project