0

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 ?

DavidZ
  • 21
  • 6
  • Check this discussion https://stackoverflow.com/questions/47823506/exception-in-thread-main-java-lang-noclassdeffounderror-org-openqa-selenium-w/47845104#47845104 – undetected Selenium Feb 15 '18 at 12:47
  • Thanks for the hint but i always run mvn clean first and i deleted my repository and let it run again. But it still does not work. And the real question is why it is even looking for Selenium. – DavidZ Feb 15 '18 at 16:48
  • Now I think, it's not an issue with Selenium-dependencies. I created a LoginPage-class that i injected into the test class with `@Page private LoginPage loginPage;` and now i also have to add the LoginPage.class to the Shrinkwrap, even though i do not need it in the container. – DavidZ Feb 16 '18 at 08:16
  • You are right !!! – undetected Selenium Feb 16 '18 at 08:17

1 Answers1

0

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.

DavidZ
  • 21
  • 6