如何使用MockMvc检查响应主体中的字符串

如何使用MockMvc检查响应主体中的字符串,第1张

如何使用MockMvc检查响应主体中的字符串

@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"

因此,这证明它有效!



欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/5130601.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-11-17
下一篇2022-11-17

发表评论

登录后才能评论

评论列表(0条)

    保存