We have a Java project where unit tests are written using Spock (Groovy). We use SonarQube for static analysis. However, we do not see the test coverage reported by SonarQube. But it lists Groovy tags in the Unit Tests section.
In the SonarQube (6.x) server, we installed the Groovy plug-in (1.5) and it lists the Groovy tests in the "Unit Tests" section. The following are the SonarQube properties set at the top level of the module. We use Gradle (3.4) with the SonarQube (2.5) plugin to build.
sonarqube { properties { property "sonar.projectKey", "ABC" property "sonar.projectName", "Abc Project" property "sonar.sourceEncoding", "UTF-8" property "sonar.sources", "src/main/java" property "sonar.tests", "src/test/groovy" } }
When I run JaCoCo through Gradle to generate HTML reports, it displays the coverage correctly. However, when we try to publish SonarQube, the following magazines will appear. It seems that SonarQube cannot find Java sources to determine coverage.
Sensor GroovySurefireSensor [groovy] (done) | time=25ms Sensor Groovy CoberturaSensor [groovy] No Cobertura report provided (see 'sonar.groovy.cobertura.reportPath' property) Sensor Groovy CoberturaSensor [groovy] (done) | time=0ms Sensor Groovy JaCoCo [groovy] Checking binary directory: /var/lib/jenkins/workspace/Abc-Analysis/common/build/classes/main Analysing /var/lib/jenkins/workspace/abc-Analysis/common/build/jacoco/test.exec Analysing /var/lib/jenkins/workspace/abc-Analysis/common/build/jacoco/test.exec File not found: com/abc/common/core/Permission.java ...
source share