简体   繁体   English

声纳不检查Android项目中的测试类

[英]Sonar not inspecting tests classes in Android project

I configured sonar on my android project that contain many flavors. 我在包含多种风格的android项目中配置了声纳。 Sonar works fine except that it doesn't show the test coverage in my app. 声纳工作正常,除了它不显示我的应用程序中的测试范围。 I set sonar properties in my gradle file like that: 我像这样在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"

As i said, I have many flavors, Under the build/intermediates/classes , I have a folder for every flavor and the test folder. 就像我说的,我有很多口味,在build/intermediates/classes ,我有一个文件夹用于每种口味和测试文件夹。

Note: the same config works in a project without any flavor ! 注意:同一配置在没有任何味道的项目中有效!

Please add these properties : 请添加以下属性:

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"

} }

and delete the sonar plugin and use the sonar-runner plugin instead. 并删除声纳插件,而改用声纳运行器插件。

the problem was with binary path. 问题出在二进制路径上。 I must specifie the path with the specific flavor. 我必须指定具有特定风味的路径。 In my case: 就我而言:

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"
//...
}
}

Where qa is my flavor and debug is the build config. qa是我的风格,debug是构建配置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM