test的方法不能带参数
@Test public void executeTests(String urlname) throws Exception { ResultActions result = mockMvc.perform(MockMvcRequestBuilders.get(urlname)) .andExpect(MockMvcResultMatchers.status().isOk()) .andDo(MockMvcResultHandlers.print()); String contentAsString = result.andReturn().getResponse().getContentAsString(); JResult jResult = JSONObject.parseObject(contentAsString, JResult.class); Assert.assertEquals("0",jResult.getCode()); } } }