📜  springboot mongodb test - 任何代码示例

📅  最后修改于: 2022-03-11 15:00:05.756000             🧑  作者: Mango

代码示例1
@RunWith(SpringRunner.class)
@DataMongoTest
public class FooRepositoryTest {

    @Autowired
    FooRepository fooRepository;

    @Before
    public void setUp() throws Exception {
        fooRepository.save(new Foo());
    }

    @Test
    public void shouldBeNotEmpty() {
        assertThat(fooRepository.findAll()).isNotEmpty();
    }
}



Dependencies


    org.springframework.boot
    spring-boot-starter-data-mongodb


    de.flapdoodle.embed
    de.flapdoodle.embed.mongo
    test