public static String getLine ( JUnitTestData testMethod ) { String line = "~" ; Throwable testException = testMethod . getFailException ( ) ; if ( testException != null ) { StringBuilder lookFor = new StringBuilder ( ) ; lookFor . append ( extractClassName ( testMethod . getDescription ( ) ) ) ; lookFor . append ( ' ' ) ; lookFor . append ( extractMethodName ( testMethod . getDescription ( ) ) ) ; lookFor . append ( ' ' ) ; lookFor . append ( extractSimpleClassName ( testMethod . getDescription ( ) ) ) ; lookFor . append ( ".java:" ) ; StackTraceElement [ ] els = testException . getStackTrace ( ) ; for ( int i = 0 ; i < els . length ; i ++ ) { StackTraceElement el = els [ i ] ; line = getLineNumberFromExceptionTraceLine ( el . toString ( ) , lookFor . toString ( ) ) ; if ( line . equals ( "" ) == Boolean . FALSE ) { break ; } } } return line ; }
Get the line of the error in the exception info