junit Cobertura Maven插件报告中类声明级别的红色复选标记是什么意思?

xfyts7mz  于 2022-11-11  发布在  Maven
关注(0)|答案(1)|浏览(153)

我有一个项目有几个测试和Cobertura Maven Plugin。所有的工作都很好,但一个类与它的测试是让我发疯。
这是cobertura报告,行覆盖率为83%:

这是最基本的测试:

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的数字并且为绿色。

环境

  • Java 8语言
  • 乌班图
  • 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>

次尝试

我尝试在我的@测试中进行几次更改,但报告没有更改!!

  • 使用extends TestCase
  • 使用@RunWith
  • 使用maven-surefire插件包括**/* 测试.java
  • 删除pom.xml中的阈值

研究

mcdcgff0

mcdcgff01#

这意味着默认的构造函数没有被测试。也许,你可以添加一个测试方法到new TimeHelper()来解决它。

相关问题