unit-testing - Grails断言-验证断言在单元测试中是否失败

标签 unit-testing grails

Grails新手问题:

当您在Grails Controller 中有assert [condition]时,如何验证断言在单元测试中失败?

我在想类似shouldFail(Exception) { .. }的东西,但是我不确定要捕获什么异常。

谢谢

最佳答案

您可以使用AssertionError

shouldFail(AssertionError) {
  assert 'one' == 'two'
}

关于unit-testing - Grails断言-验证断言在单元测试中是否失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16545313/

相关文章:

c# - FakeItEasy:重置假电话历史/忽略电话

spring - 配置grails spring security ldap插件

debugging - Netbeans 6.7是否无法在Grails应用程序中调试Groovy闭包?

grails - 从微服务中获取数据以保证其正常运行

c# - 断言数组在 Visual Studio 2008 测试框架中是相等的

.net - 什么是好的策略?在没有默认 Virtual 的情况下使用 C# 中的 Mock 进行测试

php - PHPunit 配置文件 phpunit.xml.dist 或 phpunit.xml 的命名有什么不同吗

hibernate - 以编程方式处理 Grails 事务

sorting - Grails:对嵌套域对象进行排序

node.js - 使用 Jest 动态模拟依赖关系