用弹簧进行junit测试

时间:2015-06-05 17:55:14

标签: java spring junit

我为删除做了以下测试方法。 现在我的测试状态为200,我需要在调用webservice后测试该学生被删除 我用这个代码

    .andExpect(jsonPath("$.id").value(s.getId().intValue()))

但得到异常json不能为null或emty,任何人都可以帮助我如何测试删除方法?

 @Test
 public void testDelete() throws Exception {
    Student s = data.getAll();
    ResultActions perform =    
    mockMvc.perform(delete(studentWebservice.URL+"/{id}",m.getId())
            );
    perform.andDo(print())
        .andExpect(status().isOk())
    .andExpect(jsonPath("$.id").value(s.getId().intValue()))
    .andExpect(jsonPath("$.name").value(s.name))
    ;
    }

0 个答案:

没有答案