6 Replies Latest reply on Sep 6, 2012 3:16 PM by aslak

    Arquillian + Selenium interface tests run twice each. Why?

    gatperdut

      Hallo,

       

      Wishing to test the interface of a web application, we integrated arquillian and selenium to run a few tests to check its behaviour.

      Currently we launch these tests with Maven, package goal, and a glassfish 3.1 container. The problem we are facing is that each

      individual test is run twice, and therefore the execution fails after one or at most two of them are executed.

       

      @RunWith(Arquillian.class)

      @RunAsClient

      public class TestMediaSelenium {

       

          // load ajocado driver

          @Drone

          GrapheneSelenium driver;

       

          // Load context path to the test

          @ArquillianResource

          URL contextPath;

       

          @Deployment

          public static WebArchive createWar(){

              return Deployments.createDeployment();

          }

       

            @Before

          public void login() throws MalformedURLException {

              ...

          }

          @Test

          public void advancedSearch() throws InterruptedException {

               ....

          }

       

          // More tests ...

      }

       

      The deployment is created this way in the Deployments class:

       

           public static WebArchive createDeployment() {

              try {

                  ArchivePath path = new BasicPath("src/main/webapp/common");

                  WebArchive war = addWebResourcesTo(ShrinkWrap.create(WebArchive.class, "newmedia2.war"),new File(WEBAPP_SRC));

                  war= addResourcesTo(war, new File(RESOURCES_SRC));

                  war.addPackages(true, TimeConverter.class.getPackage(),Constants.class.getPackage(),BundleToUTF8.class.getPackage(),ActionsContainer.class.getPackage(),

                          ConceptBean.class.getPackage(),AssetUrlResolver.class.getPackage(),ExiftoolThread.class.getPackage(),GenericAnnotationUtils.class.getPackage());

       

                  if (IS_JETTY) {

                      war.addAsWebInfResource(new File("src/test/resources/jetty-env.xml"), "jetty-env.xml");

                  }

                  System.out.println(war.toString(true)); // for debugging

                  return war;

              } catch (Exception e) {

                  // TODO Auto-generated catch block

                  e.printStackTrace();

              }

              return null;

          }

       

          private static WebArchive addResourcesTo(WebArchive archive,File directory)

          {

             Collection<File>files = FileUtils.listFiles(directory, null, true);

             for (File file : files)

             {

                if (!file.isDirectory()){

       

                    if (!file.getParent().contains(".svn") && !file.getName().endsWith(".css")){

                        archive.addAsResource(file, file.getPath().substring(RESOURCES_SRC.length()));

                    }

       

                }else{

                    if (!file.getName().contains(".svn")){

                        System.out.println(file.getName());

                        addWebResourcesTo(archive, file);

                    }else{

                        System.out.println(file.getName());

                    }

       

                }

             }

             return archive;

          }

       

           Another issue we've found is that the different Asserts throughout the tests don't matter when it comes to stop the execution. This is, even if

      the conditions make the assert false, the test execution continues regardless of it, but truth is this is a secondary matter.

       

        Could someone please help us out? I am not sure I've provided all the info which would be expected, I was hoping someone may have already faced

      this issue before.

       

      Thanks in advance,

      cR.

        • 1. Re: Arquillian + Selenium interface tests run twice each. Why?
          aslak

          How are you running Maven ?

          • 2. Re: Arquillian + Selenium interface tests run twice each. Why?
            gatperdut

            mvn package -P glassfish-embedded-3.1

             

            where glassfish-embedded-3.1 is the name of the profile which tells maven to use glassfish. Initially the maven goal was 'test' and changed it to

            'package', in case the double execution was caused by a) maven + b) selenium, but it didnt make any difference.

            • 3. Re: Arquillian + Selenium interface tests run twice each. Why?
              aslak

              hmm, sounds odd.. Could you share your pom.xml?

              • 4. Re: Arquillian + Selenium interface tests run twice each. Why?
                gatperdut

                I tried to keep the pom.xml short by deleting irrelevant parts; still, it's pretty long:

                 

                <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/maven-v4_0_0.xsd">

                    <modelVersion>4.0.0</modelVersion>

                    <groupId>SMMS</groupId>

                    <artifactId>media</artifactId>

                    <version>1.0.2-SNAPSHOT</version>

                    <packaging>war</packaging>

                    <name>playence media</name>

                    <properties>

                        <richfaces.version>4.1.0.Final</richfaces.version>

                        <org.richfaces.bom.version>4.1.0.Final</org.richfaces.bom.version>

                        <hotfix-revision-start>1200</hotfix-revision-start>

                        <hotfix-revision-end>1210</hotfix-revision-end>

                        <arquillian.jetty.version>1.0.0.CR1</arquillian.jetty.version>

                        <version.jsfunit>2.0.0.Beta2</version.jsfunit>

                        <version.arquillian>1.0.0.CR7</version.arquillian>

                        <arquillian.tomcat.version>1.0.0.CR2</arquillian.tomcat.version>

                        <version.arquillian.jboss>1.0.0.CR7</version.arquillian.jboss>

                        <version.shrinkwrap>1.0.0-beta-5</version.shrinkwrap>

                        <version.shrinkwrap.descriptors>1.1.0-beta-1</version.shrinkwrap.descriptors>

                        <arquillian.glassfish.version>1.0.0.CR1</arquillian.glassfish.version>

                        <glassfish.vesion>3.1</glassfish.vesion>

                        <pl.taglibs.version>1.0.2-SNAPSHOT</pl.taglibs.version>

                        <spring-version>3.0.2.RELEASE</spring-version>

                        <spring-security-taglibs-version>0.5</spring-security-taglibs-version>

                        <version.arquillian.drone>1.0.0.CR4</version.arquillian.drone>

                    </properties>

                    <dependencyManagement>

                        <dependencies>

                            <dependency>

                                <groupId>org.richfaces</groupId>

                                <artifactId>richfaces-bom</artifactId>

                                <version>${org.richfaces.bom.version}</version>

                                <scope>import</scope>

                                <type>pom</type>

                            </dependency>

                            <dependency>

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

                                <artifactId>arquillian-drone-bom</artifactId>

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

                                <type>pom</type>

                                <scope>import</scope>

                            </dependency>

                        </dependencies>

                    </dependencyManagement>

                    <dependencies>

                 

                        ...

                 

                        <dependency>

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

                            <artifactId>arquillian-junit-container</artifactId>

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

                            <scope>test</scope>

                        </dependency>

                 

                        <dependency>

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

                            <artifactId>arquillian-protocol-servlet</artifactId>

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

                            <scope>test</scope>

                        </dependency>

                 

                        <dependency>

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

                            <artifactId>arquillian-container-spi</artifactId>

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

                            <scope>test</scope>

                        </dependency>

                 

                        <dependency>

                            <groupId>org.jboss.jsfunit</groupId>

                            <artifactId>jsfunit-arquillian</artifactId>

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

                            <scope>test</scope>

                        </dependency>

                 

                        <dependency>

                            <groupId>org.jboss.jsfunit</groupId>

                            <artifactId>jboss-jsfunit-core</artifactId>

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

                            <scope>test</scope>

                        </dependency>

                 

                        <dependency>

                            <groupId>org.jboss.shrinkwrap.descriptors</groupId>

                            <artifactId>shrinkwrap-descriptors-impl</artifactId>

                            <version>${version.shrinkwrap.descriptors}</version>

                            <scope>test</scope>

                        </dependency>

                 

                        <dependency>

                            <groupId>org.jboss.shrinkwrap.resolver</groupId>

                            <artifactId>shrinkwrap-resolver-api-maven</artifactId>

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

                            <scope>test</scope>

                        </dependency>

                 

                        <dependency>

                            <groupId>org.jboss.shrinkwrap.resolver</groupId>

                            <artifactId>shrinkwrap-resolver-impl-maven</artifactId>

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

                            <scope>test</scope>

                        </dependency>

                 

                        <dependency>

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

                            <artifactId>arquillian-drone-webdriver-depchain</artifactId>

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

                            <type>pom</type>

                            <scope>test</scope>

                        </dependency>

                        <dependency>

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

                            <artifactId>arquillian-drone-selenium-depchain</artifactId>

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

                            <type>pom</type>

                            <scope>test</scope>

                        </dependency>

                        <dependency>

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

                            <artifactId>arquillian-graphene</artifactId>

                            <version>1.0.0.CR3</version>

                            <type>pom</type>

                            <scope>test</scope>

                        </dependency>

                        <dependency>

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

                            <artifactId>arquillian-junit-standalone</artifactId>

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

                            <scope>test</scope>

                        </dependency>

                 

                 

                        <dependency>

                            <groupId>org.apache.httpcomponents</groupId>

                            <artifactId>httpclient</artifactId>

                            <version>4.1.3</version>

                            <scope>test</scope>

                        </dependency>

                    </dependencies>

                 

                    <build>

                 

                        <plugins>

                            <plugin>

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

                                <artifactId>maven-compiler-plugin</artifactId>

                                <version>2.3.2</version>

                                <configuration>

                                    <source>1.5</source>

                                    <target>1.5</target>

                                </configuration>

                            </plugin>

                            <plugin>

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

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

                                <version>2.11</version>

                                <configuration>

                                    <skipTests>true</skipTests>

                                </configuration>

                            </plugin>

                 

                            <plugin>

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

                                <artifactId>maven-jar-plugin</artifactId>

                                <version>2.3.2</version>

                                <configuration>

                                    <excludes>

                                        <exclude>WEB-INF/lib/hibernate-annotations*.jar</exclude>

                                        <exclude>WEB-INF/lib/slf4j-jdk14-*.jar</exclude>

                                        <exclude>WEB-INF/lib/jcl-over-slf4j-*.jar</exclude>

                                        <exclude>WEB-INF/lib/google-collections-*.jar</exclude>

                                        <!-- <exclude>WEB-INF/lib/hibernate-commons-annotations*.jar</exclude> -->

                                    </excludes>

                                </configuration>

                            </plugin>

                 

                        </plugins>

                 

                        <finalName>newmedia</finalName>

                 

                    </build>

                 

                        <profile>

                            <id>glassfish-embedded-3.1</id>

                            <dependencies>

                                <dependency>

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

                                    <artifactId>arquillian-glassfish-embedded-3.1</artifactId>

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

                                    <scope>test</scope>

                                </dependency>

                                <dependency>

                                    <groupId>org.glassfish.extras</groupId>

                                    <artifactId>glassfish-embedded-all</artifactId>

                                    <version>${glassfish.vesion}</version>

                                    <scope>test</scope>

                                </dependency>

                            </dependencies>

                            <build>

                 

                                <plugins>

                                    <plugin>

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

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

                                        <configuration>

                                            <argLine>-Xms256m -Xmx512m -XX:MaxPermSize=256m

                                                -XX:+CMSClassUnloadingEnabled -XX:+CMSClassUnloadingEnabled</argLine>

                                            <skipTests>false</skipTests>

                                        </configuration>

                                    </plugin>

                                </plugins>

                            </build>

                        </profile>

                        <profile>

                            <id>jbossas-remote-7</id>

                            <dependencies>

                                <dependency>

                                    <groupId>org.jboss.as</groupId>

                                    <artifactId>jboss-as-arquillian-container-remote</artifactId>

                                    <version>7.0.1.Final</version>

                                    <scope>test</scope>

                                </dependency>

                            </dependencies>

                            <build>

                                <plugins>

                                    <plugin>

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

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

                                        <configuration>

                                            <skipTests>false</skipTests>

                                        </configuration>

                                    </plugin>

                                </plugins>

                            </build>

                        </profile>

                    </profiles>

                </project>

                • 5. Re: Arquillian + Selenium interface tests run twice each. Why?

                  I had this problem once. I noticed that it only happened when 'arquillian-junit-container' and 'arquillian-junit-standalone' dependencies were placed together.

                  I fixed that reorganizing my dependencies so they were never resolved together.

                   

                  I have no idea why that happens.

                  • 6. Re: Arquillian + Selenium interface tests run twice each. Why?
                    aslak

                    Oh sorry, seems I missed to responde here.

                     

                    Yes, the problem is including both x-standalone and x-contianer.

                     

                    The reason is that they are both entry points to setup the dependencies. x-standalone is used when you don't want support for Containers/Deployments while x-container add the dependencies to handle Containers and Deployment. Both of them register a listener for Test. x-standalone executes test locally only, while x-container can handle local and incontainer.

                     

                    It's a bit of a lagacy oddity from the module split in Arq 1.0. Expect this to change in the future.