简体   繁体   中英

Grails assert - verify that assertion failed in unit test

Grails newbie question:

when you have assert [condition] in a Grails controller, how do you verify that the assertion fails from a unit test?

I'm thinking something like shouldFail(Exception) { .. } but I'm not sure what exception to catch.

Thanks

You can use AssertionError .

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM