javaselenium-webdriverjunitjboss-arquillianarquillian-drone

Arquillian Drone Test with @RunAsClientSide-annotated test method and in-container test method runs with NoClassDefFoundError


The Arquillian-Guide Functional Testing using Drone and Graphene says that it is possible to "mix in-container and client modes in the same test". I am trying to run this little example:

import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.container.test.api.TargetsContainer;
import org.jboss.arquillian.drone.api.annotation.Drone;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.junit.InSequence;
import org.jboss.arquillian.spring.integration.test.annotation.SpringWebConfiguration;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.jboss.shrinkwrap.resolver.api.maven.Maven;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.openqa.selenium.WebDriver;

import java.io.File;

@RunWith(Arquillian.class)
@SpringWebConfiguration
public class ClientAndContainerTest {

@Deployment
@TargetsContainer("process")
public static WebArchive createDeployment() {
    File warFile = new File("src/test/resources/webApp.war");
//        File[] testLibs = Maven.resolver().loadPomFromFile("pom.xml")
//                .resolve("org.seleniumhq.selenium:selenium-chrome-driver")
//                .withTransitivity().asFile();
    return ShrinkWrap
            .createFromZipFile(WebArchive.class, warFile)
//          .addAsLibraries(testLibs)
            ;
}

@Test
@InSequence(1)
public void testContainerSide() {
    // test some in-container stuff
}

@Drone
private WebDriver browser;

@Test
@InSequence(2)
@RunAsClient
public void testClientSide() {
    // Run some UI-tests
}

}

The testclientSide() passes without problems. But the testContainerSide() runs with a

java.lang.NoClassDefFoundError: Lorg/openqa/selenium/WebDriver;
Caused by: java.lang.ClassNotFoundException: org.openqa.selenium.WebDriver

A soon as i add selenium-chrome-driver dependencies with Transitivity to the Deployment (uncomment the lines in the createDeployment()-Method) it works. But i don't see the point in adding Selenium to the container-deployment because it should only be needed on client side.

Can anybody tell me why testContainerSide() method is looking for org.openqa.selenium.WebDriver ?


Solution

  • I think, the only solution is to seperate ui-/client-side-tests from in-container-tests by using one test-class for each.

    If you want to use both techniques in one test-case, you can use arquillian-suite extension to run both tests-classes concurrently within a single deployment.