Provide support for "per unit test coverage" reports in sonarqube

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?

I like that idea, at the moment I can’t see a simple way to achieve that as there is no way to add a custom junit RunListener to a task of type Test. I’ve raised GRADLE-2895 for this.

cheers, René

I submitted a pull request how I think this could work: https://github.com/gradle/gradle/pull/416