October 2018
Intermediate to advanced
982 pages
23h 29m
English
Testing against an embedded MongoDB instance is quite handy. But there are times when we need to work with a real instance, and for multiple reasons: security settings, a batch of live data, a customized configuration. Whatever the reason, there is no need for that to derail our testing efforts.
We can write another test class, LiveImageRepositoryTests, and make it look like this:
@RunWith(SpringRunner.class)
@DataMongoTest(excludeAutoConfiguration =
EmbeddedMongoAutoConfiguration.class)
public class LiveImageRepositoryTests {
@Autowired
ImageRepository repository;
@Autowired
MongoOperations operations;
The details for this preceding live test are as follows:
Read now
Unlock full access