[英]Grails assert - verify that assertion failed in unit test
Grails newbie question: Grails新手问题:
when you have assert [condition]
in a Grails controller, how do you verify that the assertion fails from a unit test? 当您在Grails控制器中assert [condition]
时,如何验证断言是否因单元测试而失败?
I'm thinking something like shouldFail(Exception) { .. }
but I'm not sure what exception to catch. 我在shouldFail(Exception) { .. }
但我不确定要捕获什么异常。
Thanks 谢谢
You can use AssertionError
. 您可以使用AssertionError
。
shouldFail(AssertionError) {
assert 'one' == 'two'
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.