What is the recommended way of running an end to end integration test for multiple Spring
boot applications in the Maven
build's verify phase?
Basically, I have a multi-module Maven project where several modules are separate spring boot applications. These separate applications have their own configuration for data sources, integration flows with JMS
queues, etc. For example, application A will poll a database for an event, and when that occurs, it produces a JSON
file of data and puts a message on a JMS
queue. Application B is polling the JMS
queue, so picks up the message, reads the file, does some processing using another database, and puts a message on a different queue. Application C will then pick up that message, etc, etc.
I have set up integration tests for the individual applications; these run under the Maven failsafe plugin. However, I would like to integration test the whole system, end to end, under Maven. I have set up a separate module in the project dedicated to this task, and so would like the verify build phase of this module to do the end to end testing using the other dependent modules.
Is there a best practice way of doing this? I see 3 potential ways:
Maven
build/failsafe plugin?The simplest way to run integration tests is to use the Maven failsafe plugin. By default, the Maven surefire plugin executes unit tests during the test phase, while the failsafe plugin runs integration tests in the integration-test phase.
As explained above, for integrating testing of a spring-boot application, we need to use @SpringBootTest. spring-boot also does provide other classes like TestRestTemplate to test the REST APIs. Like RestTemplate class, it also does have methods getForObject(), postForObject(), exchange(), etc..
In this case, integration tests work like a health check that identifies pain points to address. As for E2E testing, it is a testing type that automatically simulates user experience when working with the tool relying on the so-called user stories.
Unit tests run in isolation while integration tests bootstrap the Spring web context before execution starts. UNIT TESTS. Running in isolation will sometimes require that you mock your dependencies based on the class you are testing.
Just to follow-up and say what I ended up doing (which is continuing to work well):
I hope that's useful - it was certainly refreshing to find that whatever I needed to do, a Maven plugin existed to take care of it!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With