Not able to get it test coverage in sonarqube

790 views
Skip to first unread message

Nandlalaji Singh

unread,
May 30, 2016, 10:21:10 AM5/30/16
to SonarQube

I know many people got such similar problem. i show many answars, tried the sample code given on sonar site. that sample is working fine. Also i show following link

How to configure multi-module Maven + Sonar + JaCoCo to give merged coverage report?

But nothing seems working in my case. Its not showing IT Test Coverage in sonarqube though mvn clean intsall is making jacoco folder in site where index.html is having test coverage. i tried almost every thing on net but not able to resolve issue. its a multi module project I am using

java8.

sonarqube 4.5.6 with java plugin 2.5.1.

maven 3.0.5

please help me resolve this.

Below is parent module pom file


<build>
<pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>${jacoco-maven-plugin.version}</version>
            </plugin>
        </plugins>
    </pluginManagement>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>${maven-compiler-plugin.version}</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <configuration>
                <append>true</append>
            </configuration>
            <executions>
                <execution>
                    <id>pre-unit-test</id>
                    <goals>
                        <goal>prepare-agent</goal>
                    </goals>    
                    <configuration>
                        <destFile>${project.basedir}/target/jacoco.exec</destFile>
                        <propertyName>surefireArgLine</propertyName>
                    </configuration>
                </execution>
                <execution>
                    <id>post-unit-test</id>
                    <phase>test</phase>
                    <goals>
                        <goal>report</goal>
                    </goals>
                    <configuration>
                        <!-- Sets the path to the file which contains the execution data. -->
                        <dataFile>${project.build.directory}/../target/jacoco.exec</dataFile>
                    </configuration>
                </execution>
                <execution>
                    <id>pre-integration-test</id>
                    <phase>pre-integration-test</phase>
                    <goals>
                        <goal>prepare-agent</goal>
                    </goals>
                    <configuration>
                        <destFile>${project.basedir}/../target/jacoco-it.exec</destFile>
                        <propertyName>failsafe.argLine</propertyName>
                    </configuration>
                </execution>
                <execution>
                    <id>post-integration-test</id>
                    <phase>post-integration-test</phase>
                    <goals>
                        <goal>report</goal>
                    </goals>
                    <configuration>
                        <dataFile>${project.basedir}/../target/jacoco-it.exec</dataFile>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>${maven-surefire-plugin.version}</version>
            <configuration>
                <!-- Sets the VM argument line used when unit tests are run. -->
                <argLine>${surefireArgLine}</argLine>   
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>${maven-failsafe-plugin.version}</version>
            <configuration>
                <argLine>${failsafe.argLine}</argLine>
                <includes>
                    <include>**/*Test.java</include>
                </includes>
            </configuration>
            <executions>
                <execution>
                    <id>integration-test</id>
                    <goals>
                        <goal>integration-test</goal>
                    </goals>
                </execution>
                <execution>
                    <id>verify</id>
                    <goals>
                        <goal>verify</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <!-- automatic label creation -->

    </plugins>  
  </build>
    <!-- Plugin to generate unit test coverage in SonarQube 4.5.x report. -->   

<reporting>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <configuration>
            <use>false</use>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-report-plugin</artifactId>
            <version>${maven-surefire-report-plugin.version}</version>
            <configuration>
                <alwaysGenerateFailsafeReport>true</alwaysGenerateFailsafeReport>
                <alwaysGenerateSurefireReport>true</alwaysGenerateSurefireReport>
                <aggregate>true</aggregate>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>${jacoco-maven-plugin.version}</version>
            <configuration>
                <excludes>
                    <exclude>**/*.mar</exclude>
                    <exclude>${jacoco.excludePattern}</exclude>
                </excludes>
            </configuration>
        </plugin>
    </plugins>
</reporting>

Properties in same pom file

   <sonar.java.codeCoveragePlugin>jacoco</sonar.java.codeCoveragePlugin>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <sonar.jacoco.reportPath>${project.basedir}/../target/jacoco.exec</sonar.jacoco.reportPath>    <!-- This is the default, put here to be explicit -->
    <sonar.jacoco.itReportPath>${project.basedir}/../target/jacoco-it.exec</sonar.jacoco.itReportPath>
    <sonar.language>java</sonar.language>
    <sonar.java.binaries>${project.basedir}/../target/classes</sonar.java.binaries>
    <jacoco-maven-plugin.version>0.7.4.201502262128</jacoco-maven-plugin.version>
    <maven-compiler-plugin.version>3.5.1</maven-compiler-plugin.version>
    <maven-surefire-report-plugin.version>2.19.1</maven-surefire-report-plugin.version>
    <maven-surefire-plugin.version>2.16</maven-surefire-plugin.version>
    <maven-failsafe-plugin.version>2.16</maven-failsafe-plugin.version>

mvn clean install is creating jacoco folder with index.html for test coverage but mvn sonar:sonar is not showing it in sonarqube

what mistake i am making.

in mvn sonar:sonar, it builds successfully and one of the line is JaCoCoSensor: JaCoCo report not found.

what could be the reason

i seriously feel this a bug with jacoco or sonarqube. May be it would not be compatible with java 8 or something. I tried almost every thing. Many things are deprecated with sonar java plugin 2.5.1. Please help me, i need the solution desperately

Michael Gumowski

unread,
Jun 2, 2016, 4:59:40 AM6/2/16
to Nandlalaji Singh, SonarQube
Hello,

You are using a pretty old version of the java plugin (2.5.1), although the latest version of the java plugin compatible with SonarQube 4.5.6 is 3.13.1.
Since 2.5.1, numerous fixes related to handling of JaCoCo reports have been done.

Did you tried updating the version of the Java Plugin?
Could you provide the logs of your analysis?

Regards,

Michael GUMOWSKI | SonarSource
Software Developer @ Language Team
http://sonarsource.com

--
You received this message because you are subscribed to the Google Groups "SonarQube" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarqube+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/8247734b-5911-40ec-8a00-a800aa677541%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages