Web Integration Testing

The seed-testing module provide tools for testing your code, including Web applications through Arquillian.

Web testing support requires the following dependencies in your project:

<dependency>
    <groupId>org.seedstack.seed</groupId>
    <artifactId>seed-testing</artifactId>
    <scope>test</scope>
</dependency>
Show version
dependencies {
    testCompile("org.seedstack.seed:seed-testing:3.4.1")
}

<dependency>
    <groupId>org.seedstack.poms</groupId>
    <artifactId>arquillian-composite</artifactId>
    <type>pom</type>
    <scope>test</scope>
</dependency>
Show version
dependencies {
    testCompile("org.seedstack.poms:arquillian-composite:3.1.1")
}

Be sure to specify the test scope for these dependencies.

Arquillian tests allow you to programmatically define the Web archive (WAR) and test it either from server-side or from client-side.

To declare a Web integration test, make your JUnit test class extends AbstractSeedWebIT:

public class RestIT extends AbstractSeedWebIT {
    @Deployment
    public static WebArchive createDeployment() {
        // You can use this method to customize the deployed archive
        return ShrinkWrap.create(WebArchive.class);
    }
    
    @Test
    @RunAsClient
    public void myRestResourceIsWorking(@ArquillianResource URL baseURL) {
        expect().statusCode(200).when().get(baseURL.toString() + "rest/my-resource");
    }		
}

In this example, the test method, named myRestResourceIsWorking, is a client-side test. It is executed in a separate thread and can invoke the deployed Web application through the URL provided by the @ArquillianResource annotated parameter.

Apache Tomcat is the default test server configured. You can override this choice by specifying a custom arquillian.xml file at the root of the classpath. Arquillian provides many more features than described in this section. For more information about Arquillian, visit the official website.

The test class is instantiated by Arquillian and as such cannot be intercepted. It can still be injected.

   

On this page


Edit