Does anybody have any tips, or does anybody know how I can test the "error message" returned by the HTTP response object?
@Autowired
private WebApplicationContext ctx;
private MockMvc mockMvc;
@Before
public void setUp() throws Exception {
mockMvc = MockMvcBuilders.webAppContextSetup(ctx).build();
}
Response:
MockHttpServletResponse:
Status = 200
Error message = null
Headers = {Content-Type=[application/json;charset=UTF-8]}
Content type = application/json;charset=UTF-8
assertEquals("expected error message", "actual error message")
instead of.andExpect(model().hasNoErrors())
– Vinchenzo Aug 13 '14 at 18:07