我想休息我休息班Spring MVC中春季启动 - 测试用例 - 不要加载所有组件
如果我运行下面的代码(运行良好时,该项目是小,但现在失败),它会尝试加载我的应用程序中的所有不同组件。 这包括与外部系统进行交互,需要为了凭据连接
@RunWith(SpringRunner.class)
@SpringBootTest
@AutoConfigureMockMvc
public class TestDummyRest extends BaseRestTestCase{
@Autowired
private MockMvc mockMvc;
@MockBean
private IDummyServices mockDummyServices;
@Test
public void getSendGoodMessage() throws Exception {
given(mockDummyServices.sendGoodMessage(Mockito.anyString())).willReturn(true);
mockMvc.perform(get("/dummy"))
.andExpect(status().isOk())
.andExpect(content().contentType(TEXT_PLAIN_CONTENT_TYPE));
verify(mockDummyServices, times(1)).sendGoodMessage(Mockito.anyString());
}
}
我怎么告诉我的测试类不加载我的应用程序的@Configuration或@Component类豆?
感谢 达明
非常感谢@ninj - 这真是一种享受,真的加快了我的测试用例的执行速度 –