springboot的junit4模拟request、response对象

关键字:

MockHttpRequest、Mock测试

问题:

在模拟junit的request、response对象时,会报如下空指针异常。

处理方法:

可用MockHttpServletRequest、MockHttpServletResponse代替即可。

在测试类上可加注解@SpringBootTest(classes = xxxApplication.class),标明由xxxApplication是springboot的启动类。

 

posted on 2018-10-17 10:38  骆流年kk  阅读(1230)  评论(0编辑  收藏  举报