我在 Sonar 中的代码覆盖率显示为 0%,这是不正确的,因为我确实有单元测试。
摇篮
sonarqube {
properties {
property "sonar.binaries", "build/intermediates/classes/release"
property "sonar.java.binaries", "build/intermediates/classes/release"
property "sonar.java.test.binaries", "build/intermediates/classes/test/release"
property "sonar.sources", "src"
property "sonar.junit.reportsPath", "build/reports/tests/release"
property "sonar.java.junit.reportsPath", "build/reports/tests/release"
property "sonar.android.lint.report", "build/outputs/lint-results.xml"
property "sonar.jacoco.reportPath", "${project.buildDir}/jacoco/testReleaseUnitTest.exec"
}
}
当我打开index.html
内部时build/reports/tests/release
,我可以看到成功的单元测试。
我在我sonarqube
的gradle task
Jenkins 环境中运行。我的 SonarQube 实例显示除了Code Smells
0 %之外的所有内容。code coverage
更新
我确实index.html
为代码覆盖率创建了一个,但这也都显示为 0%:
app/build/reports/jacoco/jacocoTestDebugUnitTestReport/html/index.html
更新
仍然得到 0% 但这是我到目前为止所拥有的:
android {
...
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
testCoverageEnabled true
}
debug {
testCoverageEnabled true
}
}
jacoco {
version "0.7.8.201607051106"
}
}