1

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:

r1

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.

enter image description here

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

JRichardsz
  • 14,356
  • 6
  • 59
  • 94
  • possible duplicate of [Code coverage does not reach class declaration](https://stackoverflow.com/questions/46477696/code-coverage-does-not-reach-class-declaration) – geocodezip Nov 13 '20 at 00:40
  • Please give explanations for down votes, I'd like to learn more. – JRichardsz Nov 13 '20 at 04:27
  • Does this answer your question? [Code coverage does not reach class declaration](https://stackoverflow.com/questions/46477696/code-coverage-does-not-reach-class-declaration) – Joe Nov 15 '20 at 13:36

1 Answers1

0

it means default constructor is not tested.maybe, you can add a test method to new TimeHelper() for resolve it.

darker
  • 1
  • 1