5 Replies Latest reply on Mar 25, 2014 6:03 AM by matthiasbalke

    Arquillian Jacoco Glassfish

    hss3

      Hello

       

      As far as i understood the other discussions here the maven configuration below should create me a jacoco.exec, but it does not.

      I'm just wondering if i make a misstake somewhere or if the arquillian-jacoco extension doesn't work with glassfish.

       

      Maven pom

         <dependencies>
           ...
          <dependency>
              <groupId>org.jboss.arquillian.junit</groupId>
              <artifactId>arquillian-junit-container</artifactId>
              <scope>test</scope>
          </dependency>
          <dependency>
              <groupId>org.jboss.arquillian.container</groupId>
              <artifactId>arquillian-glassfish-embedded-3.1</artifactId>
              <version>1.0.0.CR3</version>
              <scope>test</scope>
          </dependency>
          <dependency>
              <groupId>org.glassfish.main.extras</groupId>
              <artifactId>glassfish-embedded-all</artifactId>
              <version>3.1.2</version>
              <scope>test</scope>
          </dependency>
          <dependency>
              <groupId>org.jboss.arquillian.extension</groupId>
              <artifactId>arquillian-jacoco</artifactId>
              <version>1.0.0.Alpha5</version>
              <scope>test</scope>
          </dependency>
          <dependency>
              <groupId>org.jacoco</groupId>
              <artifactId>org.jacoco.core</artifactId>
              <version>0.6.0.201210061924</version>
              <scope>test</scope>
          </dependency>
          </dependencies>
      
          <dependencyManagement>
          <dependencies>
              <dependency>
              <groupId>org.jboss.arquillian</groupId>
              <artifactId>arquillian-bom</artifactId>
              <version>1.0.3.Final</version>
              <scope>import</scope>
              <type>pom</type>
              </dependency>
          </dependencies>
          </dependencyManagement>
      

       

      Arquillian.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <arquillian xmlns="http://jboss.org/schema/arquillian"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="
              http://jboss.org/schema/arquillian
              http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
      
          <container qualifier="glassfish-embedded" default="true">
              <configuration>
                  <property name="resourcesXml">
                      src/test/resources/embedded-glassfish/glassfish-resources.xml
                  </property>
                  <property name="bindHttpPort">9000</property>
              </configuration>
          </container>
      
      </arquillian>
      

       

      TestClass

      @RunWith(Arquillian.class)
      public class KeyManagerTest {
      
      
          public KeyManagerTest() {
          }
      
      
          @Deployment
          public static JavaArchive createDeployment() {
          JavaArchive ja = ShrinkWrap.create(JavaArchive.class)
              .addPackage(KeyManager.class.getPackage())
              .addAsManifestResource("test-persistence.xml", "persistence.xml")
              .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
          return ja;
          }
      ...
      }
      
        • 1. Re: Arquillian Jacoco Glassfish
          jfrenetic

          Hi!

           

          I'm not familiar with JaCoCo and JaCoCo Arquillian Extension, but I could try to guess

           

          Maybe, you need to add JaCoCo extension configuration to your arquillian.xml:

           

          <extension qualifier="jacoco">

              <property name="includes">some.package.*</property>

              <property name="excludes">some.package.*</property>

          </extension>

           

          I just had a brief look at jacoco extension sources and didn't find that jacoco.exec is generated somewhere. Moreover jacoco-extension integration tests use jacoco-maven-plugin with the following configuration:

           

          <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>

           

          So, I guess that prepare-agent plugin goal is responsible for jacoco.exec generation.

           

          It's also sad that this extension doesn't have any documentation

          • 2. Re: Arquillian Jacoco Glassfish
            hss3

            I tried the above suggestion, but it did not help.

            The part below runs event if we dont use the arquillan-extension.

             

            But thanks for your help. We'll just wait for a stable release.

            • 3. Re: Arquillian Jacoco Glassfish
              matthiasbalke

              I have the same problem, getting in container code coverage with arquillian, embedded glassfish and jacoco to work.

               

              The arquillian-jacoco-extension uses Wildfly for testing. I tried to get the tests working with Embedded Glassfish 3.1.2.2 but I can't figure out how to achieve this. Is it supported yet? Where can I find the documentation?

              It would be awesome, if one of the developers of this extension could add an example configuration for glassfish usage to their test cases or an example project, or at least tell me whats wrong with my configuration:

               

              pom.xml:

              https://github.com/matthiasbalke/arquillian-extension-jacoco/commit/74519099573ed4c6e04ac9320fef45325d982198

               

              log:

              https://travis-ci.org/matthiasbalke/arquillian-extension-jacoco/jobs/21427730

              • 4. Re: Re: Arquillian Jacoco Glassfish
                kwintesencja

                Hi guys,

                 

                i have it working with EAP 6.2, i'll share my config:

                .

                <profile>
                            <id>jacoco</id>
                            <properties>     
                                <jacoco.version>0.6.5.201403032054</jacoco.version>
                            </properties>
                            <dependencies>
                                <dependency>
                                    <groupId>org.jboss.arquillian.extension</groupId>
                                    <artifactId>arquillian-jacoco</artifactId>
                                    <scope>test</scope>
                                    <version>1.0.0.Alpha6</version>
                                </dependency>
                                <dependency>
                                    <groupId>org.jacoco</groupId>
                                    <artifactId>org.jacoco.core</artifactId>
                                    <scope>test</scope>
                                    <version>${jacoco.version}</version>
                                </dependency>
                            </dependencies>
                            <build>
                                <plugins>
                                    <plugin>
                                        <groupId>org.jacoco</groupId>
                                        <artifactId>jacoco-maven-plugin</artifactId>
                                        <version>${jacoco.version}</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>
                        </profile>
                
                

                 

                Also if you use sonar and want covarage to be readed from it you need to declare the following properties on you pom:

                <sonar.core.codeCoveragePlugin>jacoco </sonar.core.codeCoveragePlugin>

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

                <sonar.jacoco.reportPath>${project.basedir}/target/jacoco.exec</sonar.jacoco.reportPath>

                 

                so when i want to generate the coverage report i just activate jacoco profile:

                clean install -Parquillian-managed -Pjacoco

                        -Darquillian.serverHome=/opt/jboss-eap/

                 

                i hope that helps.

                • 5. Re: Re: Arquillian Jacoco Glassfish
                  matthiasbalke

                  Hi Rafael, thank you for sharing your config.

                  But the question was how to get it working with glassfish. It seems that glasfish is not yet supported.


                  If anybody has a working glassfish, arquillian and jacoco config, please share it here.