2 Replies Latest reply on Apr 12, 2014 1:37 PM by gpoul

    Test coverage in arquillian containers

    gpoul

      When testing an arquillian container implementation I currently have a single arquillian.xml in the test part of the container module. To get better test coverage I would like to test with different variations of the arquillian.xml parameters. Is it possible somehow to use different arquillian.xmls during mvn test? What's the best way to do this?

        • 1. Re: Test coverage in arquillian containers
          kpiwko

          Hi Gerhard,

           

           

          there are two approach, somehow similar, depending on your exact needs.

           

           

          If you just need different configuration of container, you can put multiple configurations with different qualifier into arquillian.xml

           

           

          <container qualifier="foo">
          ....
          </container>
          
          
          <container qualifier="bar">
          ....
          </container>
          

           

           

          Later on, you define arquillian.launch system property, with value bar or foo. The most convenient way is probably to define multiple executions in surefire and add this as system property there:

           

           

            <plugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-surefire-plugin</artifactId>
                  <executions>
                    <execution>
                      <!-- run all tests except for system tests and the big memory test -->
                      <id>foo-tests</id>
                      <phase>test</phase>
                      <goals>
                        <goal>test</goal>
                      </goals>
                      <configuration>
                        <reportNameSuffix>foo</reportNameSuffix>
                        <systemPropertyVariables>
                          <arquillian.launch>foo</arquillian.launch>
                        </systemPropertyVariables>
                      </configuration>
                    </execution>
                    <execution>
                      <!-- run all tests except for system tests and the big memory test -->
                      <id>bar-tests</id>
                      <phase>test</phase>
                      <goals>
                        <goal>test</goal>
                      </goals>
                      <configuration>
                        <reportNameSuffix>bar</reportNameSuffix>
                        <systemPropertyVariables>
                          <arquillian.launch>bar</arquillian.launch>
                        </systemPropertyVariables>
                      </configuration>
                    </execution>
                  </executions>
                </plugin>
          

           

          If that does not fit your needs, you can use the very same concept, but use arquillian.xml system property that points to arquillian.xml file. That way you can have completely different setup per execution.

           

           

          Note: The biggest problem with executions is that you can't execute single test easily - all executions are always executed - and their settings are not propagated to IDE. So in IDE you would need to setup arquillian.launch/arquillian.xml yourself. I personally prefer creating a wrapper over Maven command, so you have better control when you want to run single scenario onaly

           

           

          HTH,

           

           

          Karel

          • 2. Re: Test coverage in arquillian containers
            gpoul

            thank you so much! - This was really helpful and I just used this to implement the tests for arquillian-container-was/wlp-managed-8.5.

             

            The only thing I want to mention for anyone else who needs this is that the execution/id needs to be default-test for one of the executions as otherwise the implicit default-test still seems to be executed. This appears to be a "feature" starting with maven 2.2.