如何使用 Cobertura Maven 插件查看 HTML 覆盖率报告?
我想生成并查看 Java-Maven 项目的覆盖率报告。
我已将以下内容添加到 pom.xml
中:
<reporting>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<formats>
<format>html</format>
</formats>
</configuration>
</plugin>
</plugins>
</reporting>
当我运行 mvn cobertura:cobertura
时,它会成功构建并向控制台报告 Cobertura 报告生成成功< /code> 但我找不到该报告。
如果我 cd
进入 target/cobertura
,我会找到一个名为 cobertura.ser
的文件,但我不知道如何处理它。
编辑:重新检查文档后,感谢 Andreas_D,我添加了
标记,但得到了相同的结果。
I want to generate and view a coverage report for a Java-Maven project.
I've added the following to pom.xml
:
<reporting>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<formats>
<format>html</format>
</formats>
</configuration>
</plugin>
</plugins>
</reporting>
When I run mvn cobertura:cobertura
it builds successfully and reports to the console that Cobertura Report generation was successful
but I can't find the report.
If I cd
into target/cobertura
I find a file called cobertura.ser
but I have no idea what to do with it.
Edit: After re-examining the docs, thanks to Andreas_D, I've added the <reporting>
tag, but get the same result.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
在“构建”部分中:
然后在“报告”部分中:
执行
mvn cobertura:cobertura
然后在 target/site/cobertura/ 中查找 index.html文件夹。
This in the Build section:
And then this in the Reporting section:
Execute
mvn cobertura:cobertura
Then look for index.html inside the target/site/cobertura/ folder.
查看插件的文档,有一个示例 。非常确定您必须添加
元素才能实际生成报告。Have a look at the plugin's documentation, there's an example. Pretty sure that you have to add a
<reporting>
element to actually produce the report.我刚刚在我的项目中尝试过,您也可以执行以下操作:
a) 运行 mvn cobertura:cobertura
b) 它应该生成一个名为“site”的文件夹
c) 您可以在任何浏览器中打开index.html(在site/sobertura文件夹内)并检查覆盖结果。
I just tried here in my project, you can do the following also:
a) run mvn cobertura:cobertura
b) it should generate a folder called 'site'
c) you can open the index.html (inside site/sobertura folder) in whatever browser and inspect the results of coverage.
如果不起作用 - 试试这个
http://technikes.com /how-to-generate-code-coverage-report-in-java-jacoco-graphical-report/ 你可以获得 html 和 xml 格式的代码覆盖率报告
这太棒了,因为我以 html 和 xml 发布了我的报告
If nothing works - Try this
http://technikes.com/how-to-generate-code-coverage-report-in-java-jacoco-graphical-report/ you can get code coverage report in html and xml format
This is amazing as I publish my report in html and xml