We have a Java project where the unit tests are written using Spock (Groovy). We use SonarQube for static analysis. However, we don't see the test coverage reported in SonarQube. But it lists the Groovy tests under Unit Tests section.
In SonarQube server (6.x) we have installed the Groovy Plugin (1.5) and it lists the Groovy tests under Unit Tests. Below are the SonarQube properties that are set at the top module level. We use Gradle (3.4) with SonarQube plugin (2.5) for building.
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 the HTML reports, it shows the coverage correctly. However when we try to publish to SonarQube, following logs appear. It seems that SonarQube is unable to find the 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
...