private void handleTestRunFailed(String errorMsg){
  errorMsg=(errorMsg == null ? "Unknown error" : errorMsg);
  Log.i(LOG_TAG,String.format("Test run failed: %s",errorMsg));
  String testRunStackTrace="";
  if ((mCurrentTestResult != null) && (mCurrentTestResult.isComplete())) {
    TestIdentifier testId=new TestIdentifier(mCurrentTestResult.mTestClass,mCurrentTestResult.mTestName);
    Map<String,String> emptyMap=Collections.emptyMap();
    if (mCurrentTestResult.hasStackTrace()) {
      testRunStackTrace=mCurrentTestResult.getTrace();
    }
    for (    ITestRunListener listener : mTestListeners) {
      listener.testFailed(ITestRunListener.TestFailure.ERROR,testId,"No test results.\r\n" + testRunStackTrace);
      listener.testEnded(testId,emptyMap);
    }
    clearCurrentTestResult();
  }
  for (  ITestRunListener listener : mTestListeners) {
    listener.testRunFailed(errorMsg);
    listener.testRunEnded(mTotalRunTime,getRunMetrics());
  }
}

private void handleTestRunFailed ( String errorMsg ) { errorMsg = ( errorMsg == null ? "Unknown error" : errorMsg ) ; Log . i ( LOG_TAG , String . format ( "Test run failed: %s" , errorMsg ) ) ; String testRunStackTrace = "" ; if ( ( mCurrentTestResult != null ) && ( mCurrentTestResult . isComplete ( ) ) ) { TestIdentifier testId = new TestIdentifier ( mCurrentTestResult . mTestClass , mCurrentTestResult . mTestName ) ; Map < String , String > emptyMap = Collections . emptyMap ( ) ; if ( mCurrentTestResult . hasStackTrace ( ) ) { testRunStackTrace = mCurrentTestResult . getTrace ( ) ; } for ( ITestRunListener listener : mTestListeners ) { listener . testFailed ( ITestRunListener . TestFailure . ERROR , testId , "No test results.\r\n" + testRunStackTrace ) ; listener . testEnded ( testId , emptyMap ) ; } clearCurrentTestResult ( ) ; } for ( ITestRunListener listener : mTestListeners ) { listener . testRunFailed ( errorMsg ) ; listener . testRunEnded ( mTotalRunTime , getRunMetrics ( ) ) ; } }
process an instrumentation run failure
