summaryrefslogtreecommitdiffstats
path: root/test-runner/src
diff options
context:
space:
mode:
authorBrett Chabot <brettchabot@android.com>2010-07-08 19:10:29 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2010-07-08 19:10:29 -0700
commitbbfe0b2264703c243e2e74631abd26fdf4459e36 (patch)
treee47eac80284822babe166ef4b099d9830010bbcc /test-runner/src
parentd8a6271bb1da4ee2a8ae126b532f1b5f302decb8 (diff)
parent243f7f85ea9e57716590b9cf355e55d1f0236fce (diff)
downloadframeworks_base-bbfe0b2264703c243e2e74631abd26fdf4459e36.zip
frameworks_base-bbfe0b2264703c243e2e74631abd26fdf4459e36.tar.gz
frameworks_base-bbfe0b2264703c243e2e74631abd26fdf4459e36.tar.bz2
am 243f7f85: am f6120cf4: Merge "Improve InstrumentationTestRunner exception handling." into gingerbread
Merge commit '243f7f85ea9e57716590b9cf355e55d1f0236fce' * commit '243f7f85ea9e57716590b9cf355e55d1f0236fce': Improve InstrumentationTestRunner exception handling.
Diffstat (limited to 'test-runner/src')
-rw-r--r--test-runner/src/android/test/InstrumentationTestRunner.java22
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) {