8 Replies Latest reply on Sep 18, 2018 3:01 AM by nickarls

    arquillian-jacoco extension working?

    nickarls

      Anyone got it to work on a remote connector?

       

      I have

       

      <project xmlns="http://maven.apache.org/POM/4.0.0"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
      <modelVersion>4.0.0</modelVersion>
      <groupId>fi.affecto.nik</groupId>
      <artifactId>jacoco</artifactId>
      <version>0.0.1-SNAPSHOT</version>
      
      
      <properties>
      <maven.compiler.source>1.8</maven.compiler.source>
      <maven.compiler.target>1.8</maven.compiler.target>
      <version.jacoco>0.8.1</version.jacoco>
      <version.arquillian_jacoco>1.0.0.Alpha9</version.arquillian_jacoco>
      </properties>
      
      
      <dependencyManagement>
      <dependencies>
      <dependency>
      <groupId>org.jboss.arquillian</groupId>
      <artifactId>arquillian-bom</artifactId>
      <version>1.4.0.Final</version>
      <scope>import</scope>
      <type>pom</type>
      </dependency>
      </dependencies>
      </dependencyManagement>
      
      
      <dependencies>
      <dependency>
      <groupId>org.jboss.spec</groupId>
      <artifactId>jboss-javaee-7.0</artifactId>
      <version>1.1.1.Final</version>
      <type>pom</type>
      <scope>provided</scope>
      </dependency>
      <dependency>
      <groupId>org.jboss.arquillian.junit</groupId>
      <artifactId>arquillian-junit-container</artifactId>
      <scope>test</scope>
      </dependency>
      <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.12</version>
      <scope>test</scope>
      </dependency>
      <dependency>
      <groupId>org.wildfly.arquillian</groupId>
      <artifactId>wildfly-arquillian-container-remote</artifactId>
      <version>2.1.0.Final</version>
      <scope>test</scope>
      </dependency>
      <dependency>
      <groupId>org.jacoco</groupId>
      <artifactId>org.jacoco.core</artifactId>
      <version>${version.jacoco}</version>
      <scope>test</scope>
      </dependency>
      <dependency>
      <groupId>org.jboss.arquillian.extension</groupId>
      <artifactId>arquillian-jacoco</artifactId>
      <version>${version.arquillian_jacoco}</version>
      <scope>test</scope>
      </dependency>
      </dependencies>
      
      
      <build>
      <plugins>
      <plugin>
      <groupId>org.jacoco</groupId>
      <artifactId>jacoco-maven-plugin</artifactId>
      <version>${version.jacoco}</version>
      <executions>
      <execution>
      <goals>
      <goal>prepare-agent</goal>
      </goals>
      </execution>
      <execution>
      <id>report</id>
      <phase>prepare-package</phase>
      <goals>
      <goal>report</goal>
      </goals>
      </execution>
      </executions>
      </plugin>
      </plugins>
      </build>
      </project>
      

       

      I see the agent launched, the test is executed on the remote container, the reports are generate but coverage shows 0%

       

      pointers?

        • 1. Re: arquillian-jacoco extension working?
          nickarls

          Umm. When exporting the test archive, I don't see any jacoco-stuff included. How can it instrument stuff on the remote JVM?

          • 2. Re: arquillian-jacoco extension working?
            nickarls

            In https://github.com/arquillian/arquillian-extension-jacoco/issues/21 bmajsak mentioned a forthcoming howto, any news on that?

            • 3. Re: arquillian-jacoco extension working?
              nickarls

              Any help would be... helpful

              • 4. Re: arquillian-jacoco extension working?
                isidoros

                I got it working with the following configuration both on remote and managed container on wildfly 13.

                <sonar.java.codeCoveragePlugin>jacoco</sonar.java.codeCoveragePlugin>

                   <jacoco.out.ut.file>${project.basedir}/target/jacoco-ut.exec</jacoco.out.ut.file>

                   <jacoco.out.it.file>${project.basedir}/target/jacoco-it.exec</jacoco.out.it.file>

                <sonar.jacoco.reportPaths>${jacoco.out.ut.file}</sonar.jacoco.reportPaths>

                   <sonar.junit.reportPaths>${project.basedir}/target/surefire-reports</sonar.junit.reportPaths>

                <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>

                <version.arquillian.jacoco>1.0.0.Alpha8</version.arquillian.jacoco>

                <jacoco.version>0.7.4.201502262128</jacoco.version>

                 

                <dependencyManagement>

                   <dependencies>

                   <dependency>

                   <groupId>org.wildfly.bom</groupId>

                   <artifactId>wildfly-javaee7-with-tools</artifactId>

                   <version>${version.jboss.bom}</version>

                   <type>pom</type>

                   <scope>import</scope>

                   </dependency>

                </dependencyManagement>

                 

                <dependencies>

                   <dependency>

                   <groupId>org.jacoco</groupId>

                   <artifactId>org.jacoco.core</artifactId>

                   <version>${jacoco.version}</version>

                   <scope>test</scope>

                   </dependency>

                   <dependency>

                   <groupId>org.jboss.arquillian.extension</groupId>

                   <artifactId>arquillian-jacoco</artifactId>

                   <version>${version.arquillian.jacoco}</version>

                   <scope>test</scope>

                   </dependency>

                   <dependency>

                   <groupId>org.sonarsource.java</groupId>

                   <artifactId>sonar-jacoco-listeners</artifactId>

                   <version>3.8</version>

                   <scope>test</scope>

                   </dependency>

                </dependencies>

                 

                 

                <profile>

                   <id>proddev</id>

                   <build>

                   <plugins>

                   <plugin>

                   <groupId>org.jacoco</groupId>

                   <artifactId>jacoco-maven-plugin</artifactId>

                   <version>${jacoco.version}</version>

                   <executions>

                   <execution>

                   <id>test</id>

                   <goals>

                   <goal>prepare-agent</goal>

                   </goals>

                   <configuration>

                   <!-- Sets the path to the file which contains the execution data. -->
                   <destFile>${jacoco.out.ut.file}</destFile>

                   <append>true</append>

                   </configuration>

                   </execution>

                   </executions>

                   </plugin>

                   <plugin>

                   <groupId>org.apache.maven.plugins</groupId>

                   <artifactId>maven-surefire-plugin</artifactId>

                   <version>${version.surefire.plugin}</version>

                   <configuration>

                   <failIfNoTests>false</failIfNoTests>

                   <properties>

                   <property>

                   <name>listener</name>

                   <value>org.sonar.java.jacoco.JUnitListener</value>

                   </property>

                   </properties>

                   </configuration>

                   </plugin>

                   </plugins>

                   </build>

                </profile>

                 

                Since it I have a multimodule project in each child pom with tests I have this in pom

                 

                <profile>

                   <id>proddev</id>

                   <dependencies>

                   <dependency>

                   <groupId>org.wildfly.arquillian</groupId>

                   <artifactId>wildfly-arquillian-container-remote</artifactId>

                   <scope>test</scope>

                   </dependency>

                   </dependencies>

                   <build>

                   <plugins>

                   <plugin>

                   <artifactId>maven-surefire-plugin</artifactId>

                   <version>${version.surefire.plugin}</version>

                   <configuration>

                   <systemPropertyVariables>

                   <arquillian.launch>widlfly-remote</arquillian.launch>

                   </systemPropertyVariables>

                   </configuration>

                   </plugin>

                   </plugins>

                   </build>

                </profile>

                 

                I hope it will help you

                1 of 1 people found this helpful
                • 5. Re: arquillian-jacoco extension working?
                  nickarls

                  Thanks, I'll try to distill that down to a bare minimum

                  • 6. Re: arquillian-jacoco extension working?
                    nickarls

                    It would be interesting to know how the arquillian jacoco extension is supposed to work in a docker environment. I assume the bytecode enhanchement is done to the test archive in the normal way but what happens next?

                    Since the actual test executions happens in a different JVM/container, does that WildFly have to be started with some agent? And aren't the execution statistics generated in the container? How is it supposed to be fetched into the JVM that started the build?

                    • 7. Re: arquillian-jacoco extension working?
                      nickarls

                      The arquillian-jacoco docs say that

                       

                      When using the Arquillian Jacoco Extension with Sonar you only need to depend on the Arquillian Jacoco Extension. Sonar will handle the setup of Jacoco for you.

                       

                      apparently you still need the sonar-jacoco-listeners hooked up(?)

                      • 8. Re: arquillian-jacoco extension working?
                        nickarls

                        I my jenkins console output I see

                         

                        [INFO] Analysing /var/jenkins_home/workspace/Concept7/target/jacoco.exec

                        [INFO] No information about coverage per test.

                         

                        the jacoco.exec has other content, though so it looks like jacoco is not picking up the executions happening in the remote server. Does it have to be started with some agent parameters?