SpringMVC 测试框架 MockMvc 天坑一枚
最近使用SpringMvc写一个URL比较复杂的RequestMapping,最后使用MockMvc测试下URL。 出现的问题是根本不存在的URI,居然返回200。使用以下代码测试: @RunWith(SpringJUnit4ClassRunner.class) @WebAppConfiguration @ContextConfiguration({ "classpath:spring/spring-web.xml" }) public class SearchControllerTest { @Autowired private WebApplicationContext wac; private MockMvc mockMvc; @Before public void setUp() throws Exception { this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build(); } @Test public void testURLMapping() throws Exception { String[] testCase= { "/asdf" // 根本不存在 }; for (String url : testCase) { this.mockMvc.perform