【问题标题】:Not able to generate HTML reports of code coverage from Clover Maven plugin无法从 Clover Maven 插件生成代码覆盖率的 HTML 报告
【发布时间】:2017-07-04 10:28:16
【问题描述】:

尝试集成 Clover maven 插件以获得我项目的代码覆盖率。

使用mvn clean install 构建项目后,目标文件夹如下所示

但我正在寻找 HTML 报告的代码覆盖率(这将为我们提供包明智、类明智的视图的代码覆盖率)

<generateHtml>true</generateHtml> 行会这样做吗?如果是,我的配置有问题。

如何从 Clover maven 插件中获取 HTML 报告?

下面是pom.xml代码

<build> 
         <plugins>
            <plugin>
        <groupId>com.atlassian.maven.plugins</groupId>
        <artifactId>maven-clover2-plugin</artifactId>
        <configuration>
        <!-- <targetPercentage>80%</targetPercentage> -->
        <generateHtml>true</generateHtml>
          <generatePdf>true</generatePdf>
          <generateXml>true</generateXml>
        </configuration>
        <executions>
          <execution>
             <phase>verify</phase>
            <goals>
               <goal>instrument</goal>
              <goal>check</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
        </plugins>
    </build>
    <reporting>
    <plugins>
      <plugin>
        <groupId>com.atlassian.maven.plugins</groupId>
        <artifactId>maven-clover2-plugin</artifactId>
        <configuration>
        <generateHtml>true</generateHtml>
          <generatePdf>true</generatePdf>
          <generateXml>true</generateXml>
        </configuration>
      </plugin>
    </plugins>
  </reporting>

【问题讨论】:

  • 您是否看到测试用例作为mvn clean install 命令的一部分执行?
  • 是的,测试用例执行完毕,构建成功

标签: maven code-coverage clover


【解决方案1】:

请使用mvn clean install clover2:clover 命令查看是否得到target/site/clover/index.html 文件中生成的html 报告。

clover2:clover 目标应该检测您的测试类、执行测试用例并记录代码覆盖率信息。

【讨论】:

  • mvn clean install clover2:clover 命令在target/site/clover/clover/index.html 下创建了 index.html,但 html 为空。它没有任何信息
  • 我需要更改配置吗?
  • 我完全使用了您的配置,对我来说效果很好。我能够看到 html 格式的代码覆盖率报告。不确定,为什么你的 html 是空的。我在您提到的目录路径中看到两个clover。这是一个错字还是您正在寻找错误的路径?
  • 不,不是拼写错误,路径完全相同 - target/site/clover/clover/index.html
  • target/site/clover 中有index.html 吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2011-11-26
  • 2020-05-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-06-26
  • 1970-01-01
相关资源
最近更新 更多