使用 Jenkins Sonar 插件构建成功后,Sonar 不显示代码覆盖率 [英] Sonar does not shows up Code Coverage after build successful with Jenkins Sonar plugin

查看:22
本文介绍了使用 Jenkins Sonar 插件构建成功后,Sonar 不显示代码覆盖率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Sonar 和 Jenkins 获得代码覆盖率.我看到 Jenkins 的 Sonar 插件成功执行 JUnit 测试用例并成功完成构建.但是 Sonar 没有在项目中显示代码覆盖率结果(总是显示 0.0% 作为代码覆盖率).但 Sonar 确实显示单元测试成功".

我正在将 Maven 与 Jenkins 和 Sonar 一起使用.

执行 Sonar 插件时,我在 Jenkins 日志中收到以下消息:

<上一页>项目覆盖率设置为 0%,因为没有转储 JaCoCo 执行数据:.../sonar/target/jacoco.exec

谁能帮助我如何在任何 Sonar 项目中获得正确的代码覆盖率.

解决方案

我看了https://docs.sonarqube.org/display/PLUG/Code+Coverage+by+Unit+Tests+for+Java+Project 并使用 cobertura 作为我的代码覆盖插件然后我看到小项目的代码覆盖率显示.当我在声纳中检查一个大项目时,我只看到代码覆盖率 - 这意味着它是空的.在日志中,我发现在/.../coverage.xml 路径中找不到 Cobertura 报告.

由于 OutOfMemeryError:heapspace 未生成coverage.xml.由于我的项目是如此之大,当我将堆内存设置为 2GB 并将 cobertura 插件内存设置为 1.5GB 时,声纳会显示代码覆盖率.

I am trying to get code coverage with Sonar and Jenkins. I see Jenkins' Sonar plugin successfully executes JUnit test cases and completes build successfully. But Sonar does not show Code Coverage results (always shows 0.0% as the code coverage) on the project. But Sonar does show "Unit test success".

I am using Maven with Jenkins and Sonar.

I get the below message in Jenkins logs while executing the Sonar plugin:

Project coverage is set to 0% as no JaCoCo execution data has been dumped: .../sonar/target/jacoco.exec

Can any one help me how to get correct code coverage on any Sonar project.

解决方案

I read https://docs.sonarqube.org/display/PLUG/Code+Coverage+by+Unit+Tests+for+Java+Project and used cobertura as my code coverage plugin then I see code coverage displays for small projects. When I check for a big project in sonar I just see code coverage as - that means its empty. In logs I could find that Cobertura report was not found at /.../coverage.xml path.

coverage.xml was not generated due to OutOfMemeryError:heapspace. Since my project is such a big project when I set heap memory to 2GB and cobertura plugin memory to 1.5GB sonar gets code coverage displayed.

这篇关于使用 Jenkins Sonar 插件构建成功后,Sonar 不显示代码覆盖率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆