sfeir-open-source / sonar-clover

It provides the ability to feed SonarQube with code coverage data coming from Atlassian Clover
Apache License 2.0
15 stars 25 forks source link

Custom reports can´t be integrated into Sonarqube #59

Closed mgonzcast closed 1 year ago

mgonzcast commented 1 year ago

I am using 8.9.8 Sonarqube LTS and maven 3.8.4 and Java 1.8.x

I have this issue with some of my tests so I am forced to use a custom report like this one:

        <clover-report>
          <current outfile="clover.xml" title="Coverage">
            <format srclevel="false" type="xml"/>
            <testsources dir="src/test" includes="/**/*.java"/>
            <testresults dir="target/surefire-reports" includes="TEST-*.xml"/>
          </current>
        </clover-report>

If use directly in pom.xml with:

                <groupId>org.openclover</groupId>
                <artifactId>clover-maven-plugin</artifactId>
                <version>4.4.1</version>
                <configuration>
                    <!-- Use custom report descriptor -->
                    <!-- <reportDescriptor>clover-report.xml</reportDescriptor> -->
                    <generateXml>true</generateXml>
                </configuration>

It gets integrated into Sonarqube but report several tests failing (because of the @Rule issue mentioned before).

Unfortunately the resulting clover.xml file is not integrated into Sonarqube reporting 0 lines to cover. Any way to achieve this?

mgonzcast commented 1 year ago

I answer myself, you need to set to format srclevel to true:

                <clover-report>
          <current outfile="clover.xml" title="Coverage">
            <format srclevel="false" type="xml"/>
            <testsources dir="src/test" includes="/**/*.java"/>
            <testresults dir="target/surefire-reports" includes="TEST-*.xml"/>
          </current>
        </clover-report>