static StackTraceElement findTestClassTraceElement(StackTraceElement[] trace){
  for (int i=trace.length - 1; i >= 0; i--) {
    StackTraceElement element=trace[i];
    if (TEST_CASE_CLASS.equals(element.getClassName()) && TEST_CASE_METHOD.equals(element.getMethodName())) {
      return trace[i - 3];
    }
  }
  throw new IllegalArgumentException("Could not find test class!");
}

static StackTraceElement findTestClassTraceElement ( StackTraceElement [ ] trace ) { for ( int i = trace . length - 1 ; i >= 0 ; i -- ) { StackTraceElement element = trace [ i ] ; if ( TEST_CASE_CLASS . equals ( element . getClassName ( ) ) && TEST_CASE_METHOD . equals ( element . getMethodName ( ) ) ) { return trace [ i - 3 ] ; } } throw new IllegalArgumentException ( "Could not find test class!" ) ; }
returns the test class element by looking at the method instrumentationtestcase invokes .
