基于注释的Spring MVC的优点之一是可以通过简单的方式对其进行测试,如下所示:
import org.junit.Test;import org.junit.Assert;import org.springframework.web.servlet.ModelAndView;public class HelloControllerTest { @Test public void testHelloController() { HelloController c= new HelloController(); ModelAndView mav= c.handleRequest(); Assert.assertEquals("hello", mav.getViewName()); ... }}这种方法有什么问题吗?
对于更高级的集成测试,Spring文档中有org.springframework.mock.web的参考。



