记录单元测试时的踩坑记录:
在webc层进行单元测试时,引入mockmvc之后。
经过:
@Before
public void setup() throws Exception {
// 初始化
MockitoAnnotations.openMocks(this);
// 构建mvc环境
mockMvc = MockMvcBuilders.standaloneSetup(operationController).build();
}
之后再使用**verify()**语句时便会报如下错:
Wanted but not invoked:
Actually, there were zero interactions with this mock.
的错误。
单元测试报错Wanted but not invoked:
最新推荐文章于 2023-02-22 23:20:51 发布