private static Object runJUnit3Test(Class scriptClass){
  try {
    Object testSuite=InvokerHelper.invokeConstructorOf("junit.framework.TestSuite",new Object[]{scriptClass});
    return InvokerHelper.invokeStaticMethod("junit.textui.TestRunner","run",new Object[]{testSuite});
  }
 catch (  ClassNotFoundException e) {
    throw new GroovyRuntimeException("Failed to run the unit test. JUnit is not on the Classpath.",e);
  }
}

private static Object runJUnit3Test ( Class scriptClass ) { try { Object testSuite = InvokerHelper . invokeConstructorOf ( "junit.framework.TestSuite" , new Object [ ] { scriptClass } ) ; return InvokerHelper . invokeStaticMethod ( "junit.textui.TestRunner" , "run" , new Object [ ] { testSuite } ) ; } catch ( ClassNotFoundException e ) { throw new GroovyRuntimeException ( "Failed to run the unit test. JUnit is not on the Classpath." , e ) ; } }
run the specified class extending testcase as a unit test . this is done through reflection , to avoid adding a dependency to the junit framework . otherwise , developers embedding groovy and using groovyshell to load / parse / compile groovy scripts and classes would have to add another dependency on their classpath .
