Reputation: 3859
I have a multi module project and I now want to add integration tests to it, I want to use the cargo plugin to start tomcat and deploy my artefacts there and then test end to end using selenium.
I have looked through the maven console output for my current build and surefire unit tests and then read the maven docs for the failsafe plugin this looks ok but it looks like the life cycle is for each module as the logs indicate that a module is tested then built before moving onto the next module.
Am I understanding this correctly?
As my app consists of a war that is the front end only which then connects to the backend api app which is a rest api that connects to the database I need to have both war files deployed to cargo in the integration test phase at the same time.
Does anybody know how to do this or can point me to a tutorial that does integration tests between multiple war files in tomcat?
Thanks
Upvotes: 3
Views: 3262
Reputation: 24637
The Maven plugin lifecycle is as follows:
org.mockserver can be used for the aforementioned purpose of testing multiple war files.
To run MockServer as part of your build add the following plugin to your pom.xml:
<plugin>
<groupId>org.mock-server</groupId>
<artifactId>mockserver-maven-plugin</artifactId>
<version>3.10.7</version>
<configuration>
<serverPort>1080</serverPort>
<proxyPort>1090</proxyPort>
<logLevel>DEBUG</logLevel>
<initializationClass>org.mockserver.maven.ExampleInitializationClass</initializationClass>
</configuration>
<executions>
<execution>
<id>process-test-classes</id>
<phase>process-test-classes</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>verify</id>
<phase>verify</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
This will start MockServer during the process-test-classes phase and will stop MockServer during the verify phase. For more details about Maven build phases see: Introduction to the Build Lifecycle.
This ensures that any integration tests you run during the test or integration-test phases can use MockServer on the port specified.
A full example demonstrates MVC integration.
Upvotes: 4