Configure in your maven project a simple integration test looks complex but it really isn’t.
Belolw you see the configuration of the plugin’s with their configuration i will shortly explain the items
maven-failsafe-plugin
Use the maven failsafe plugin to run your integration tests. You can use the maven-surefire-plugin but this plugin will halt on the integration-test phase if there occurs an error. This behavior looks valid because you don’t want to install or deploy any code if an integration-test fails but the effect is that the post-integration are not executed. There for the application server and selenium server started in the pre-integration phase keep running and you will have a problem to start them again with the next build.
The failsafe plugin solves this by not halting the build process if a test fails but stores the test results in the testreports. During the verify phase the test reports are evaluated and the build process will be halted if there where any failing tests.
example configuration
Below a part of my configuration file, notice the following things:
- failsave plugin is connected to the integration-test phase and to the verify phase
- no test sources are specified. (Default all files that fit the following mask are included: “*.IT.java”)
- glassfish plugin is connected to the pre-integration-test phase and the post-integration-test phase
- selenium plugin is connected to the pre-integration-test phase and the post-integration-test phase
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>integration-test</id>
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
<execution>
<id>verify</id>
<phase>verify</phase>
<goals>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<!-- asadmin create-domain - -savemasterpassword=true webui -->
<groupId>org.glassfish.maven.plugin</groupId>
<artifactId>maven-glassfish-plugin</artifactId>
<version>2.1</version>
<configuration>
<glassfishDirectory>${glassfishDirectory}</glassfishDirectory>
<user>${glassfishUser}</user>
<passwordFile>${passwordFile}</passwordFile>
<debug>true</debug>
<echo>true</echo>
<domain>
<name>${project.artifactId}</name>
<adminPort>4848</adminPort>
</domain>
<components>
<component>
<name>${project.artifactId}</name>
<artifact>${project.build.directory}/${project.build.finalName}.war</artifact>
</component>
</components>
</configuration>
<executions>
<execution>
<id>start-gef</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start-domain</goal>
<goal>deploy</goal>
</goals>
<configuration>
<background>true</background>
<logOutput>true</logOutput>
<multiWindow>true</multiWindow>
</configuration>
</execution>
<execution>
<id>stop-gef</id>
<phase>post-integration-test</phase>
<goals>
<goal>undeploy</goal>
<goal>stop-domain</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>selenium-maven-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<id>start-sel</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start-server</goal>
</goals>
<configuration>
<background>true</background>
<logOutput>true</logOutput>
<multiWindow>true</multiWindow>
</configuration>
</execution>
<execution>
<id>stop-sel</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop-server</goal>
</goals>
</execution>
</executions>
</plugin>
Popularity: 2% [?]
Theo van Arem is a Integration specialist working at 

