0

I'm working here on some tests, I start from the bottom, reactiveRepository and successfully wrote all necessary tests with com.playtika.testcontainers.embedded-mongodb and embedded.mongodb.enabled: true in test/resources bootstrap.yml

Now I moved one layer up, to the @Services, but I spot that testcontainers still executes embedded-mongodb which I don't need, as I'm just mocking repository for Services tests:

@MockBean
private UserRepository userRepository;

@Test
blah blah blah() {
  Mockito.when(userRepository.findByUsername(loginRequest.getUsername())).thenReturn(Mono.just(fakeUser));
}

Any hints on how to exclude embedded-mongo autoconfiguration? or set embedded.mongodb.enabled: false for specific test case?

Frant
  • 5,382
  • 1
  • 16
  • 22
Bryksin
  • 2,322
  • 3
  • 19
  • 31

1 Answers1

0

you can create two separate test profiles and a bootstrap.yaml for each for that profile where one having embedded-mongodb with embedded.mongodb.enabled: true ( e.g. for integration test cases) & other one with embedded.mongodb.enabled: false (e.g. for unit test cases).

For more, you can refer this blog: https://dev.to/sivalabs/springboot-integration-testing-using-testcontainers-starter-13h2