Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

84
Views
Tests annotated with DataMongoTest do not terminate the embedded MongoDB at the end

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.

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!