Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

87
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda