question: public static Throwable shouldFail ( Class clazz , Closure code ) { Throwable th = null ; try { code . call ( ) ; } catch ( GroovyRuntimeException gre ) { th = ScriptBytecodeAdapter . unwrap ( gre ) ; } catch ( Throwable e ) { th = e ; } if ( th == null ) { fail ( "Closure " + code + " should have failed with an exception of type " + clazz . getName ( ) ) ; } else if ( ! clazz . isInstance ( th ) ) { fail ( "Closure " + code + " should have failed with an exception of type " + clazz . getName ( ) + ", instead got Exception " + th ) ; } return th ; }
target:  Asserts that the given code closure fails when it is evaluated and that a particular type of exception is thrown.