Reputation: 8353
I noticed experimentally that any integration test class annotated with @DataMongoTest
does not kill the embedded MongoDB instance it uses. To kill the embedded instance, I have to annotate the test with the annotation @DirtiesContext(classMode = ClassMode.AFTER_CLASS)
.
@RunWith(SpringRunner.class)
@DataMongoTest
@ContextConfiguration(classes = {MyRepositoryIT.class})
@EnableAutoConfiguration
@DirtiesContext(classMode = ClassMode.AFTER_CLASS)
public class MyRepositoryIT{
// The tests
}
The problem highlights when you run long pipelines of tests using Maven. The embedded Mongo instances are killed only when the whole testing process terminates.
Is it correct? Am I making something wrong?
I am using Spring Boot 2.2.10, flapdoodle library, JUnit 4, and version 4.0.2 of MongoDB. I am building the system under Windows.
Upvotes: 3
Views: 686