在运行基于Gradle的构建和集成测试后,我在"build/jacoco"文件夹中成功生成了Jacoco的2个.exec文件.
Gradle命令:"gradle clean build integrationTest"
完成后,它会在build/jacoco文件夹下生成以下.exec文件.
以下是我的sonar-project.properties文件.什么时候,我从Linux运行"sonar-runner"它完成但是在SonarQube仪表板上完成了这个项目,我看到单元测试说有34.5%,但集成测试说0.0%.两个.exec文件都有有效的大小.我也在.exec文件上做了"cat",并在Linux中将输出管道输出到"strings"命令,看到IntegrationTest.exec确实命中了测试函数 - 我只有1个.java文件.
当我运行"gradle clean build IntegrationTest sonarRunner -Dxxx.xxx = yyy -Dyyy.xx = zzz"时,即通过使用-D选项传递sonar-project.properties文件中提到的所有声纳变量,它可以工作,但结果相同SonarQube项目的仪表板.Project的声纳仪表板有两个配置为单元/集成测试的小部件,我还包括用于显示整体覆盖范围的IT测试.总体覆盖率显示为34.5%(单位测试%值).Sonar确实看到了test.exec,integrationTest.exec,并且在此操作过程中也自动生成了total-xxx.exec文件.
注意:我不在哪里 - 在Gradle构建脚本中的单独putty/linux控制台-OR上启动tomcat,为Jacoco提供任何值或设置JAVA Agent.我已经获得了integrationTest.exec文件和test.exec文件,所以不确定在IT测试完成运行后是否需要停止JVM.我不认为我需要那些,因为我有.exec文件的有效文件大小.
我的?: - 为什么声纳没有在仪表板上获得IT覆盖,即使我正确设置/传递以下变量:
sonar.jacoco.itReportPath=build/jacoco/integrationTest.exec
Run Code Online (Sandbox Code Playgroud)
-bash-3.2 $ cat sonar-project.properties
# Root project information
sonar.projectKey=com:company:product:ProjectA
sonar.projectName=ProjectA
sonar.projectVersion=1.0
# optional description
sonar.projectDescription=ProjectA Service
#Tells SonarQube that the code coverage tool by unit tests is JaCoCo
sonar.java.coveragePlugin=jacoco
#Tells SonarQube to reuse existing reports for unit tests execution and coverage reports
sonar.dynamicAnalysis=reuseReports
# Some properties that will be …Run Code Online (Sandbox Code Playgroud)