【发布时间】:2017-12-09 19:23:21
【问题描述】:
如何在 Spring MVC / HamCrest 中否定内容测试,即测试匹配器的否定:
.andExpect(content().string(containsString("StringToNOTExpect")))
【问题讨论】:
标签: spring model-view-controller hamcrest
如何在 Spring MVC / HamCrest 中否定内容测试,即测试匹配器的否定:
.andExpect(content().string(containsString("StringToNOTExpect")))
【问题讨论】:
标签: spring model-view-controller hamcrest
通过检查 hamcrest CoreMatchers 类并搜索“not”找到了答案:
import static org.hamcrest.CoreMatchers.not;
....
.andExpect(content().string(not(containsString("StringToNOTExpect"))))
【讨论】: