public static Throwable shouldFail(Class clazz,String script){
  Throwable th=null;
  try {
    GroovyShell shell=new GroovyShell();
    shell.evaluate(script,genericScriptName());
  }
 catch (  GroovyRuntimeException gre) {
    th=ScriptBytecodeAdapter.unwrap(gre);
  }
catch (  Throwable e) {
    th=e;
  }
  if (th == null) {
    fail("Script should have failed with an exception of type " + clazz.getName());
  }
 else   if (!clazz.isInstance(th)) {
    fail("Script should have failed with an exception of type " + clazz.getName() + ", instead got Exception "+ th);
  }
  return th;
}

public static Throwable shouldFail ( Class clazz , String script ) { Throwable th = null ; try { GroovyShell shell = new GroovyShell ( ) ; shell . evaluate ( script , genericScriptName ( ) ) ; } catch ( GroovyRuntimeException gre ) { th = ScriptBytecodeAdapter . unwrap ( gre ) ; } catch ( Throwable e ) { th = e ; } if ( th == null ) { fail ( "Script should have failed with an exception of type " + clazz . getName ( ) ) ; } else if ( ! clazz . isInstance ( th ) ) { fail ( "Script should have failed with an exception of type " + clazz . getName ( ) + ", instead got Exception " + th ) ; } return th ; }
asserts that the given script fails when it is evaluated and that a particular type of exception is thrown .
