Sonarqube has a feature that allows it to report on coverage per test case and coverage of lines of code by test cases as described here - https://jira.codehaus.org/browse/SONARJAVA-94
For TestNG, this is easily done as follows;
dependencies {
testRuntime
'org.codehaus.sonar-plugins.java:sonar-jacoco-listeners:1.3'
}
test.options {
listeners << 'org.sonar.java.jacoco.TestNGListener'
}
For JUnit, this seems to be impossible as there is no way to register an additional ‘RunListener’ that I can see.
The ideal situation would be for the sonar-runner plugin to spot that the jacoco plugin is there and automatically add this feature in (if the sonar plugin is configured to provide per unit test reports).
Is this feature on the radar?
Alternatively, is there a way to register this manually for junit right now that I am missing?