register
other register

Wednesday, June 23, 2010

shouldFail in Groovy Testing

If the program hasn't got code to catch the runtime unchecked exceptions, then shouldFail can be used during groovy testing. http://groovy.codehaus.org/Unit+Testing

shouldFail() allows you to check that a particular lock of code throws an exception.

shouldFail (NullPointerException) {
    testService.methodA('xxx')
}

However runtime unchecked exceptions can sometimes be considered as bugs in the programme and should be dealt with.

No comments: