Skip to content
Advertisement

How to run integration test of a spring-boot based application through maven-failsafe-plugin?

I have a spring-boot based application, and the pom.xml file is configured as below.

JavaScript

The main method located in class DemoApplication as below

JavaScript

And my integration test class called DemoIT as following.

JavaScript

Now here is my question, when I issue mvn clean verify command, the integration class DemoIT is supposed to be executed, and it does. However, my DemoApplication isn’t running. So I’m wondering if my integration test needs to be executed under the spring-boot application context (the DemoApplication needs running), what should I do to make it happen?

Advertisement

Answer

Since my application is based on Spring-Boot, and spring-boot-maven-plugin is included in pom.xml, so what I need to do is to add following configuration to make sure the lifecycle of our Spring Boot application is well managed around.

JavaScript

Then when I issue mvn clean verify, the spring boot application will be running with our integration test code.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement