Priya
Priya

Reputation: 1226

Spring boot Integration test with different database environmets

I have a set of Junit test cases . All test cases have to be executed for different database environments . When using '@RunWith(SpringJUnit4ClassRunner.class)' in junit test, the spring boot application starts only once . But I need to start the application again with different configurations including flyway migration and other environment related application-<>.properties to run the tests . I have also tried using parameterized tests . In that case too , the spring application gets started only once. Is there any way of achieving this ?

Upvotes: 1

Views: 1218

Answers (1)

Catchwa
Catchwa

Reputation: 5855

Sounds like you need to use these annotations on your tests:

@RunWith(SpringRunner.class)
@SpringBootTest
@Import(MyTestsConfiguration.class)

Refer to this page in the Spring Boot doco for further details

Upvotes: 3

Related Questions