To annotate a test class or test method to configure testing data to be inserted into certain MongoDB during integration tests.
Idea from @Sql of Spring Framework
Made by ResourceReaderRepositoryPopulator of Spring Data Mongo
Add MongoDataTestExecutionListener to your test class
@TestExecutionListeners(listeners = MongoDataTestExecutionListener.class, mergeMode = MergeMode.MERGE_WITH_DEFAULTS)
Annotate your test class or test method
@Test
@MongoData("/test-data/foo.json")
public void test() {
assertEquals(1, fooRepository.count());
}
Please see IntegrationTest.java for details.