diff options
author | Brett Chabot <brettchabot@android.com> | 2010-07-08 14:09:21 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2010-07-08 14:09:21 -0700 |
commit | f6120cf431804e072f34699a5d8a3fae62492cee (patch) | |
tree | dfc0e00fb75fe4d40949772df0dd5ffff275ce80 /test-runner/src | |
parent | 74bf59b450daf9e7e6bf234f01db164099edbfd5 (diff) | |
parent | 31e7ce762ccbbb747fabb4581e42a0a2fe56e780 (diff) | |
download | frameworks_base-f6120cf431804e072f34699a5d8a3fae62492cee.zip frameworks_base-f6120cf431804e072f34699a5d8a3fae62492cee.tar.gz frameworks_base-f6120cf431804e072f34699a5d8a3fae62492cee.tar.bz2 |
Merge "Improve InstrumentationTestRunner exception handling." into gingerbread
Diffstat (limited to 'test-runner/src')
-rw-r--r-- | test-runner/src/android/test/InstrumentationTestRunner.java | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/test-runner/src/android/test/InstrumentationTestRunner.java b/test-runner/src/android/test/InstrumentationTestRunner.java index 63d50c7..70d1643 100644 --- a/test-runner/src/android/test/InstrumentationTestRunner.java +++ b/test-runner/src/android/test/InstrumentationTestRunner.java @@ -496,9 +496,18 @@ public class InstrumentationTestRunner extends Instrumentation implements TestSu return null; } + /** + * Initialize the current thread as a looper. + * <p/> + * Exposed for unit testing. + */ + void prepareLooper() { + Looper.prepare(); + } + @Override public void onStart() { - Looper.prepare(); + prepareLooper(); if (mJustCount) { mResults.putString(Instrumentation.REPORT_KEY_IDENTIFIER, REPORT_VALUE_ID); @@ -521,6 +530,11 @@ public class InstrumentationTestRunner extends Instrumentation implements TestSu long runTime = System.currentTimeMillis() - startTime; resultPrinter.print(mTestRunner.getTestResult(), runTime); + } catch (Throwable t) { + // catch all exceptions so a more verbose error message can be outputted + writer.println(String.format("Test run aborted due to unexpected exception: %s", + t.getMessage())); + t.printStackTrace(writer); } finally { mResults.putString(Instrumentation.REPORT_KEY_STREAMRESULT, String.format("\nTest results for %s=%s", @@ -762,9 +776,11 @@ public class InstrumentationTestRunner extends Instrumentation implements TestSu TimedTest.class).includeDetailedStats(); } } catch (SecurityException e) { - throw new IllegalStateException(e); + // ignore - the test with given name cannot be accessed. Will be handled during + // test execution } catch (NoSuchMethodException e) { - throw new IllegalStateException(e); + // ignore- the test with given name does not exist. Will be handled during test + // execution } if (mIsTimedTest && mIncludeDetailedStats) { |