dbunit中mockbean失效如何解决
本篇文章给大家分享的是有关dbunit中mockbean失效如何解决,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。
2. 由于spring-test-dbunit 的注解配置,导致 mockito 中的 @MockBean 失效,需要将 MockitoTestExecutionListener 和 DbUnitTestExecutionListener 配置到 @TestExecutionListeners 中
@ActiveProfiles(value = "test") @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment= SpringBootTest.WebEnvironment.RANDOM_PORT) @TestExecutionListeners({ DependencyInjectionTestExecutionListener.class, DirtiesContextTestExecutionListener.class, TransactionDbUnitTestExecutionListener.class, MockitoTestExecutionListener.class, DbUnitTestExecutionListener.class}) @AutoConfigureMockMvc public abstract class ApplicationTests { @Test public void contextLoads() { } }
以上就是dbunit中mockbean失效如何解决,小编相信有部分知识点可能是我们日常工作会见到或用到的。希望你能通过这篇文章学到更多知识。更多详情敬请关注行业资讯频道。