Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

86
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda