@Deprecated public class GroovyAssert
Type Params | Return Type | Name and description |
---|---|---|
|
static Throwable |
shouldFail(Closure code) Asserts that the given code closure fails when it is evaluated |
|
static Throwable |
shouldFail(Class clazz, Closure code) Asserts that the given code closure fails when it is evaluated and that a particular exception is thrown. |
|
static Throwable |
shouldFailWithCause(Class clazz, Closure code) Asserts that the given code closure fails when it is evaluated and that a particular exception can be attributed to the cause. |
Asserts that the given code closure fails when it is evaluated
code
- the code expected to throw the exceptionAsserts that the given code closure fails when it is evaluated and that a particular exception is thrown.
clazz
- the class of the expected exceptioncode
- the closure that should failAsserts that the given code closure fails when it is evaluated and that a particular exception can be attributed to the cause. The expected exception class is compared recursively with any nested exceptions using getCause() until either a match is found or no more nested exceptions exist.
If a match is found the error message associated with the matching exception is returned. If no match was found the method will fail.
clazz
- the class of the expected exceptioncode
- the closure that should fail