[jbosstools-issues] [JBoss JIRA] (JBIDE-23155) tests: sonar should report test coverage

Andre Dietisheim (JIRA) issues at jboss.org
Thu Sep 15 11:19:01 EDT 2016


    [ https://issues.jboss.org/browse/JBIDE-23155?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13294045#comment-13294045 ] 

Andre Dietisheim edited comment on JBIDE-23155 at 9/15/16 11:18 AM:
--------------------------------------------------------------------

To have sonar reporting test coverage one has to include cobertura or jacoco in the build. Sonar will then pick up the report that was generated as long as required properties are configured correctly.

To add jacoco to our build the following has to be added to pom:
{code:title=http://www.eclemma.org/jacoco/trunk/doc/examples/build/pom.xml}
<build>
    <plugins>
        <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>0.7.8-SNAPSHOT</version>
            <executions>
                <execution>
                    <id>default-prepare-agent</id>
                    <goals>
                        <goal>prepare-agent</goal>
                    </goals>
                </execution>
                <execution>
                    <id>default-report</id>
                    <phase>prepare-package</phase>
                    <goals>
                        <goal>report</goal>
                    </goals>
                </execution>
                <execution>
                    <id>default-check</id>
                    <goals>
                        <goal>check</goal>
                    </goals>
                    <configuration>
                        <rules>
                            <!--  implementation is needed only for Maven 2  -->
                            <rule implementation="org.jacoco.maven.RuleConfiguration">
                                <element>BUNDLE</element>
                                <limits>
                                    <!--  implementation is needed only for Maven 2  -->
                                    <limit implementation="org.jacoco.report.check.Limit">
                                        <counter>COMPLEXITY</counter>
                                        <value>COVEREDRATIO</value>
                                        <minimum>0.60</minimum>
                                    </limit>
                                </limits>
                            </rule>
                        </rules>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
{code}


was (Author: adietish):
To have sonar reporting test coverage one has to include cobertura or jacoco in the build. Sonar will then pick up the report that was generated as long as required properties are configured correctly.

To add jacoco to our build the following has to be added to pom:
{code:title=http://www.eclemma.org/jacoco/trunk/doc/examples/build/pom.xml}
<build>
    <plugins>
        <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>0.7.8-SNAPSHOT</version>
            <executions>
                <execution>
                    <id>default-prepare-agent</id>
                    <goals>
                        <goal>prepare-agent</goal>
                    </goals>
                </execution>
                <execution>
                    <id>default-report</id>
                    <phase>prepare-package</phase>
                    <goals>
                        <goal>report</goal>
                    </goals>
                </execution>
                <execution>
                    <id>default-check</id>
                    <goals>
                        <goal>check</goal>
                    </goals>
                    <configuration>
                        <rules>
                            <!--  implementation is needed only for Maven 2  -->
                            <rule implementation="org.jacoco.maven.RuleConfiguration">
                                <element>BUNDLE</element>
                                <limits>
                                    <!--  implementation is needed only for Maven 2  -->
                                    <limit implementation="org.jacoco.report.check.Limit">
                                        <counter>COMPLEXITY</counter>
                                        <value>COVEREDRATIO</value>
                                        <minimum>0.60</minimum>
                                    </limit>
                                </limits>
                            </rule>
                        </rules>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
{code}

> tests: sonar should report test coverage
> ----------------------------------------
>
>                 Key: JBIDE-23155
>                 URL: https://issues.jboss.org/browse/JBIDE-23155
>             Project: Tools (JBoss Tools)
>          Issue Type: Sub-task
>          Components: openshift
>    Affects Versions: 4.4.1.Final
>            Reporter: Andre Dietisheim
>             Fix For: 4.4.x
>
>
> I'd be great if our sonar instance at sonarqube.com would report test coverage.
> Docs are here: http://docs.sonarqube.org/display/PLUG/Code+Coverage+by+Unit+Tests+for+Java+Project



--
This message was sent by Atlassian JIRA
(v6.4.11#64026)


More information about the jbosstools-issues mailing list