1

我有一个包含多个测试和Cobertura Maven Plugin的项目。一切正常,但一个类的测试让我发疯。

这是覆盖率 83% 的 cobertura 报告:

r1

这是基本测试:

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));
  }

}

问题

  • cobertura报告中类名左侧的0是什么意思?

其他类显示数字 > 0 并且是绿色的。

在此处输入图像描述

环境

  • 爪哇 8
  • ubuntu
  • 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>

尝试

我尝试在我的@Test 中进行一些更改,但报告没有改变!

  • 利用extends TestCase
  • 利用@RunWith
  • 使用maven-surefire-plugin包括 **/*Test.java
  • 删除 pom.xml 中的阈值

研究

4

0 回答 0