Java 在 Intellij IDEA 中打开 JaCoCo 报告
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21420621/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Open JaCoCo report in Intellij IDEA
提问by tibo
I am trying to find dead code on our application by using a code coverage tool (rather a static code analysis tool). I have chosen JaCoCo and am able to get a report thanks to the JaCoCo agent.
我试图通过使用代码覆盖工具(而不是静态代码分析工具)在我们的应用程序中找到死代码。我选择了 JaCoCo 并且能够通过 JaCoCo 代理获得报告。
I know that Intellij IDEA works with JaCoCo but I couldn't find anyway to import my JaCoCo report into Intellij IDEA. Any idea on how to do that?
我知道 Intellij IDEA 可与 JaCoCo 一起使用,但无论如何我都找不到将我的 JaCoCo 报告导入 Intellij IDEA 的方法。关于如何做到这一点的任何想法?
Thanks
谢谢
采纳答案by tibo
Found the solution. I have installed the coverage plugin and the EclEmma plugin (not sure if this one is really necessary...). Then "Analyse -> Show Coverage Data..." and pick your Jacoco output file. This file HAS to have the .exec extension, otherwise you can't select it. That was my problem...
找到了解决办法。我已经安装了coverage插件和EclEmma插件(不确定这个插件是否真的有必要......)。然后“分析 -> 显示覆盖数据...”并选择您的 Jacoco 输出文件。此文件必须具有 .exec 扩展名,否则您无法选择它。那是我的问题...
Thanks
谢谢
回答by Shakti Garg
"intellij idea" seems to have no way of showing correct coverage value of jacoco report created. It is indeed misleading and unfair when it shows coverage as 0.0 instead of giving an unsupported format error.
“intellij idea”似乎无法显示创建的 jacoco 报告的正确覆盖值。当将覆盖率显示为 0.0 而不是给出不受支持的格式错误时,这确实具有误导性和不公平性。
However, as an alternative, we can push jacoco report (created as part of maven build) to the sonar(qube) server using maven-sonar-plugin's target, sonar:sonar
但是,作为替代方案,我们可以使用 maven-sonar-plugin 的目标 sonar:sonar 将 jacoco 报告(作为 maven 构建的一部分创建)推送到声纳(qube)服务器
mvn clean install sonar:sonar -Dsonar.host.url=http://:9000-Dsonar.projectKey= -Dsonar.branch= -Dsonar.login= -Dsonar.password=
mvn clean install sonar:sonar -Dsonar.host.url= http://:9000-Dsonar.projectKey= -Dsonar.branch= -Dsonar.login= -Dsonar.password=
sonar.projectKey and sonar.branch properties value can be retrieved from corresponding project created in sonarqube.
sonar.projectKey 和 sonar.branch 属性值可以从在 sonarqube 中创建的相应项目中检索。