@Sotirios Delimanolis回答完成了这项工作,但是我一直在寻找在此模拟Mvc断言中比较字符串的方法
所以这是
.andExpect(content().string(""Username already taken - please try with different username""));当然,我的主张失败了:
java.lang.AssertionError: Response content expected:<"Username already taken - please try with different username"> but was:<"Something gone wrong">
因为:
MockHttpServletResponse: Body = "Something gone wrong"
因此,这证明它有效!



