How to test Spring CrudRepository using @DataJpaTest in Spring boot 2.1.0.M4 using Junit 5

自闭症网瘾萝莉.ら 提交于 2019-12-02 04:14:38

Do not mix @SpringBootTest with @DataJpaTest

From JavaDoc's one can read:

Annotation that can be used in combination with {@code @RunWith(SpringRunner.class)} for a typical JPA test. Can be used when a test focuses only on JPA components.

For full integration tests you should instead use @SpringBootTest

If you are looking to load your full application configuration, but use an embedded database, you should consider {@link SpringBootTest @SpringBootTest} combined with {@link AutoConfigureTestDatabase @AutoConfigureTestDatabase} rather than this annotation.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!