How to check String in response body with mockMvc

后端 未结 12 1904
遇见更好的自我
遇见更好的自我 2020-12-02 04:02

I have simple integration test

@Test
public void shouldReturnErrorMessageToAdminWhenCreatingUserWithUsedUserName()          


        
12条回答
  •  孤城傲影
    2020-12-02 04:47

    String body = mockMvc.perform(bla... bla).andReturn().getResolvedException().getMessage()
    

    This should give you the body of the response. "Username already taken" in your case.

提交回复
热议问题