@SuppressWarnings("unchecked") public boolean canRun(Class scriptClass,GroovyClassLoader loader){
  boolean isTest=false;
  try {
    try {
      Class testAnnotationClass=loader.loadClass("org.testng.annotations.Test");
      Annotation annotation=scriptClass.getAnnotation(testAnnotationClass);
      if (annotation != null) {
        isTest=true;
      }
 else {
        Method[] methods=scriptClass.getMethods();
        for (        Method method : methods) {
          annotation=method.getAnnotation(testAnnotationClass);
          if (annotation != null) {
            isTest=true;
            break;
          }
        }
      }
    }
 catch (    ClassNotFoundException e) {
    }
  }
 catch (  Throwable e) {
  }
  return isTest;
}

@ SuppressWarnings ( "unchecked" ) public boolean canRun ( Class scriptClass , GroovyClassLoader loader ) { boolean isTest = false ; try { try { Class testAnnotationClass = loader . loadClass ( "org.testng.annotations.Test" ) ; Annotation annotation = scriptClass . getAnnotation ( testAnnotationClass ) ; if ( annotation != null ) { isTest = true ; } else { Method [ ] methods = scriptClass . getMethods ( ) ; for ( Method method : methods ) { annotation = method . getAnnotation ( testAnnotationClass ) ; if ( annotation != null ) { isTest = true ; break ; } } } } catch ( ClassNotFoundException e ) { } } catch ( Throwable e ) { } return isTest ; }
utility method to check via reflection if the parsed class appears to be a testng test , i . e . checks whether it appears to be using the relevant testng annotations .
