SonarQube没有获得单元测试覆盖率

编程入门 行业动态 更新时间:2024-10-18 19:23:48
本文介绍了SonarQube没有获得单元测试覆盖率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在使用声纳获取jacoco分析报告时遇到问题.但是,詹金斯能够获取报告并显示结果. 我的项目是由詹金斯(Jenkins)构建的Maven构建. jacoco报告由maven生成(在pom中配置).声纳是通过使用Jenkins插件执行的.

I am having issues with sonar picking up the jacoco analysis report. Jenkins however is able to pick up the report and display the results. My project is a maven build, built by Jenkins. The jacoco report is generated by maven (configured in the pom). Sonar is executed by using the Jenkins plugin.

这是我在SonarQube上看到的:

This is what I see on SonarQube:

这是我在詹金斯市看到的该项目的报告.

This is the report i can see of the project in jenkins.

maven插件配置:

The maven plugin config:

<plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <version>0.6.4.201312101107</version> <executions> <execution> <id>default-prepare-agent</id> <goals> <goal>prepare-agent</goal> </goals> </execution> <execution> <id>default-report</id> <phase>prepare-package</phase> <goals> <goal>report</goal> </goals> </execution> <execution> <id>default-check</id> <goals> <goal>check</goal> </goals> </execution> </executions> </plugin>

Jenkins声纳插件配置

Jenkins Sonar Plugin config

推荐答案

您缺少一些重要的声纳属性,这是我的一个构建示例:

You were missing a few important sonar properties, Here is a sample from one of my builds:

sonar.jdbc.dialect=mssql sonar.projectKey=projectname sonar.projectName=Project Name sonar.projectVersion=1.0 sonar.sources=src sonar.language=java sonar.binaries=build/classes sonar.tests=junit sonar.dynamicAnalysis=reuseReports sonar.junit.reportsPath=build/test-reports sonar.java.coveragePlugin=jacoco sonar.jacoco.reportPath=build/test-reports/jacoco.exec

Jenkins控制台输出中的错误对于使代码覆盖范围正常工作非常有用.

The error in Jenkins console output can be pretty useful for getting code coverage to work.

项目覆盖率设置为0%,因为没有包含类的目录. 表示您没有正确设置Sonar.Binaries属性

Project coverage is set to 0% since there is no directories with classes. Indicates that you have not set the Sonar.Binaries property correctly

没有有关每次测试覆盖率的信息 表示您没有正确设置Sonar.Tests属性

No information about coverage per test Indicates you have not set the Sonar.Tests property properly

未收集覆盖率信息.也许您忘了将调试信息包含在已编译的类中?表示正确设置了sonar.binaries属性,但是这些文件不是在调试模式下编译的,因此需要对其进行

Coverage information was not collected. Perhaps you forget to include debug information into compiled classes? Indicates that the sonar.binaries property was set correctly, but those files were not compiled in debug mode, and they need to be

更多推荐

SonarQube没有获得单元测试覆盖率

本文发布于:2023-11-16 01:41:55,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1599851.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:覆盖率   单元测试   SonarQube

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!