summaryrefslogtreecommitdiffstats
path: root/test-runner
diff options
context:
space:
mode:
authorJack Wang <jackwang@google.com>2010-10-19 15:13:07 -0700
committerJack Wang <jackwang@google.com>2010-10-19 18:23:18 -0700
commit3fc03e619fb01678549b80e7a89af2c8e3f19968 (patch)
tree8219675f058c1939b7662dfd08fc284ee60e32c5 /test-runner
parent62f2ada64f7213243eafd7a4a4c3ccd5040ad85a (diff)
downloadframeworks_base-3fc03e619fb01678549b80e7a89af2c8e3f19968.zip
frameworks_base-3fc03e619fb01678549b80e7a89af2c8e3f19968.tar.gz
frameworks_base-3fc03e619fb01678549b80e7a89af2c8e3f19968.tar.bz2
Added RepetitiveTest annotation and test runner support
Change-Id: I7bf0871ede6dd69512c6b6ea3484693ba5b78e89
Diffstat (limited to 'test-runner')
-rw-r--r--test-runner/src/android/test/InstrumentationTestRunner.java26
1 files changed, 21 insertions, 5 deletions
diff --git a/test-runner/src/android/test/InstrumentationTestRunner.java b/test-runner/src/android/test/InstrumentationTestRunner.java
index 70d1643..3ac74f7 100644
--- a/test-runner/src/android/test/InstrumentationTestRunner.java
+++ b/test-runner/src/android/test/InstrumentationTestRunner.java
@@ -240,6 +240,11 @@ public class InstrumentationTestRunner extends Instrumentation implements TestSu
private static final String REPORT_KEY_RUN_TIME = "runtime";
/**
* If included in the status or final bundle sent to an IInstrumentationWatcher, this key
+ * reports the number of total iterations of the current test.
+ */
+ private static final String REPORT_KEY_NUM_ITERATIONS = "numiterations";
+ /**
+ * If included in the status or final bundle sent to an IInstrumentationWatcher, this key
* reports the guessed suite assignment for the current test.
*/
private static final String REPORT_KEY_SUITE_ASSIGNMENT = "suiteassignment";
@@ -748,6 +753,20 @@ public class InstrumentationTestRunner extends Instrumentation implements TestSu
mTestResult.putString(Instrumentation.REPORT_KEY_STREAMRESULT, "");
}
+ Method testMethod = null;
+ try {
+ testMethod = test.getClass().getMethod(testName);
+ // Report total number of iterations, if test is repetitive
+ if (testMethod.isAnnotationPresent(RepetitiveTest.class)) {
+ int numIterations = testMethod.getAnnotation(
+ RepetitiveTest.class).numIterations();
+ mTestResult.putInt(REPORT_KEY_NUM_ITERATIONS, numIterations);
+ }
+ } catch (NoSuchMethodException e) {
+ // ignore- the test with given name does not exist. Will be handled during test
+ // execution
+ }
+
// The delay_msec parameter is normally used to provide buffers of idle time
// for power measurement purposes. To make sure there is a delay before and after
// every test in a suite, we delay *after* every test (see endTest below) and also
@@ -766,9 +785,9 @@ public class InstrumentationTestRunner extends Instrumentation implements TestSu
mIncludeDetailedStats = false;
try {
// Look for TimedTest annotation on both test class and test method
- if (test.getClass().getMethod(testName).isAnnotationPresent(TimedTest.class)) {
+ if (testMethod.isAnnotationPresent(TimedTest.class)) {
mIsTimedTest = true;
- mIncludeDetailedStats = test.getClass().getMethod(testName).getAnnotation(
+ mIncludeDetailedStats = testMethod.getAnnotation(
TimedTest.class).includeDetailedStats();
} else if (test.getClass().isAnnotationPresent(TimedTest.class)) {
mIsTimedTest = true;
@@ -778,9 +797,6 @@ public class InstrumentationTestRunner extends Instrumentation implements TestSu
} catch (SecurityException e) {
// ignore - the test with given name cannot be accessed. Will be handled during
// test execution
- } catch (NoSuchMethodException e) {
- // ignore- the test with given name does not exist. Will be handled during test
- // execution
}
if (mIsTimedTest && mIncludeDetailedStats) {