利用junit对springMVC的Controller进行测试

http://zhangzhaoaaa.iteye.com/blog/2200096
平时对junit测试service/DAO层已经很熟悉不过了,如果不了解,可以猛戳这里http://zhangzhaoaaa.iteye.com/blog/2033355,但是我们要测试controller层,不能总重启服务器吧,(重启tomcat好慢的飘过,别。。。别走啊),那么我们就用junit4模拟请求,测试controller层的方法。
代码1:直接Controller调用方法

代码2:调用请求路径

注意:import static 的spring类

代码3: LoginController代码片段

参考:http://blog.csdn.net/a95473004/article/details/8926929
http://ysj5125094.iteye.com/blog/2082110