我在我的android项目中配置了包含许多风格的声纳。 Sonar工作正常,但它没有在我的应用程序中显示测试覆盖率。我在我的gradle文件中设置了声纳属性,如下所示:
property "sonar.language", "java"
property "sonar.sources", "src"
property "sonar.test", "src/test, src/androidTest/java"
property "sonar.binaries", "build"
property "sonar.jacoco.reportPath", "build/jacoco/testDebugUnitTest.exec"
property "sonar.java.coveragePlugin", "jacoco"
property "sonar.junit.reportsPath", "build/test-results/Debug"
property "sonar.android.lint.report", "build/outputs/lint-results.xml"
正如我所说,我有很多种口味,在build/intermediates/classes
下,我有一个适合各种口味的文件夹和测试文件夹。
注意:相同的配置在没有任何风味的项目中有效!
答案 0 :(得分:0)
请添加以下属性:
sonarProperties {
property "sonar.host.url", "http://sonar.someserver.int"
property "sonar.jdbc.url", "jdbc:mysql://sonar.someserver.int:3306/sonar"
property "sonar.jdbc.driverClassName", "com.mysql.jdbc.Driver"
property "sonar.jdbc.username", "*****"
property "sonar.jdbc.password", "*****"
//I added these properties to my gradle.build
property "sonar.projectKey", "GradleAndroidTest"
property "sonar.projectName", "GradleAndroidTest"
property "sonar.projectVersion", "V1.0"
property "sonar.language", "java"
property "sonar.sources", "src"
property "sonar.binaries", "build"
}
并删除声纳插件并改为使用sonar-runner插件。
答案 1 :(得分:0)
问题出在二进制路径上。我必须指定具有特定风味的路径。就我而言:
sonarqube {
//noinspection GroovyAssignabilityCheck
properties {
//...
property "sonar.binaries", "build/intermediates/classes/qa/debug"
property "sonar.java.binaries", "build/intermediates/classes/qa/debug"
property "sonar.java.test.binaries", "build/intermediates/classes/qa/debug"
//...
}
}
qa是我的风格,调试是构建配置。