jacocojboss-arquillianapache-tomeejacoco-maven-plugintomee-7

Arquillian tomee remote jacoco code coverage


I am doing integration test using Arquillian in TomEE-Plus 7.0.4 remote and trying to get Code coverage using Jacoco 0.8.2. My code coverage is not covered since I am using arquillian-tomee-remote. Since code is not covered not able to take build. I need sample code with has TomEE-plus arquillian remote and Code coverage using Jacoco. I will appreciate if I get any sample working code or sample project.

I used prepare-agent goal which will generate surefireArgLine ( javaagent) and passed the same in surefire plugin. issue here is, I am using remote Tomee and don't know how to generate correct java agent surefireArgLine set to -javaagent:/home/user/.m2/repository/org/jacoco/org.jacoco.agent/0.8.2/org.jacoco.agent-0.8.2-runtime.jar=destfile=/home/user/project/target/coverage-reports/jacoco-ut.exec,append=true,excludes=/config/*.class:/util/*Constants.class

what is the correct javaagent option for my configuration which will connect to arquillian-remote-tomee ?

Jacoco plugin

    <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <version>${plugin.maven.jacoco.version}</version>
        <configuration>
            <propertyName>coverageAgent</propertyName>
            <append>true</append>
            <excludes>
                <exclude>**/config/*.class</exclude>
                <exclude>**/util/*Constants.class</exclude>
            </excludes>
        </configuration>
        <executions>
            <execution>
                <id>pre-unit-test</id>
                <goals>
                    <goal>prepare-agent</goal>
                </goals>
                <configuration>
                    <destFile>${sonar.jacoco.reportPath}</destFile>
                    <propertyName>surefireArgLine</propertyName>
                    <append>true</append>
                </configuration>
            </execution>
            <execution>
                <id>post-unit-test</id>
                <phase>test</phase>
                <goals>
                    <goal>report</goal>
                </goals>
                <configuration>
                    <dataFile>${sonar.jacoco.reportPath}</dataFile>
                    <outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>
                    <append>true</append>
                </configuration>
            </execution>
            <execution>
                <id>check</id>
                <goals>
                    <goal>check</goal>
                </goals>
                <configuration>
                    <dataFile>${sonar.jacoco.reportPath}</dataFile>
                    <haltOnFailure>true</haltOnFailure>
                    <rules>
                        <rule>
                            <element>BUNDLE</element>
                            <limits>
                                <limit>
                                    <counter>LINE</counter>
                                    <value>COVEREDRATIO</value>
                                    <minimum>0.99</minimum>
                                </limit>
                                <limit>
                                    <counter>BRANCH</counter>
                                    <value>COVEREDRATIO</value>
                                    <minimum>0.99</minimum>
                                </limit>
                                <limit>
                                    <counter>CLASS</counter>
                                    <value>MISSEDCOUNT</value>
                                    <maximum>0</maximum>
                                </limit>
                            </limits>
                        </rule>
                    </rules>
                </configuration>
            </execution>
        </executions>
    </plugin>

Dependency

<dependency>
    <groupId>org.jboss.arquillian.testng</groupId>
    <artifactId>arquillian-testng-container</artifactId>
    <scope>test</scope>
</dependency>

<dependency>
    <groupId>org.jboss.arquillian.config</groupId>
    <artifactId>arquillian-config-api</artifactId>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.jboss.arquillian.extension</groupId>
    <artifactId>arquillian-jacoco</artifactId>
    <version>1.0.0.Alpha10</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.jacoco</groupId>
    <artifactId>org.jacoco.agent</artifactId>
    <classifier>runtime</classifier>
    <scope>test</scope>
    <version>${plugin.maven.jacoco.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jacoco/org.jacoco.core -->
<dependency>
    <groupId>org.jacoco</groupId>
    <artifactId>org.jacoco.core</artifactId>
    <version>${plugin.maven.jacoco.version}</version>
    <scope>test</scope>
</dependency>

<dependency>
    <groupId>org.apache.tomee</groupId>
    <artifactId>arquillian-tomee-remote</artifactId>
    <version>${tomee.version}</version>
    <scope>test</scope>
</dependency>

Arquillian.xml

<extension qualifier="jacoco">
    <property name="includes">com.demo.*</property>
</extension>

Solution

  • I have added the proper java agent ( surefireArgLine) to TomEE remote server via catalina opts in surefire pluggin. it works.

    surefireArgLine - Will be populate by Surefire prepare-agent at runtime.

    <tomee.catalina_opts> ${surefireArgLine}</tomee.catalina_opts>