I am trying to disable real Mongo connection and replace it with Fongo mock in tests.
Here is my test class:
keep @SpringBootTest and then create a class using @TestConfiguration with the beans in as follows:
@TestConfiguration
public class TransactionManagerTestConfiguration {
@Bean
public String getDatabaseName() {
return "FongoDB";
}
@Bean
public Mongo mongo() {
return new Fongo(getDatabaseName()).getMongo();
}
}
As per the javadoc: Configuration that can be used to define additional beans or customizations for a test. Unlike regular Configuration classes the use of TestConfiguration does not prevent auto-detection of SpringBootConfiguration.