diff options
author | Brett Chabot <brettchabot@android.com> | 2010-02-19 09:57:11 -0800 |
---|---|---|
committer | Brett Chabot <brettchabot@android.com> | 2010-02-22 18:08:35 -0800 |
commit | 88e03a97366d08fc69d852cf2219f9d0b1916af4 (patch) | |
tree | 99e50be3bfd8a264b6d84133e4e05ea59e2c50ef /test-runner/tests | |
parent | b09cc2cde25d02f668b8bc2115a9479425f48703 (diff) | |
download | frameworks_base-88e03a97366d08fc69d852cf2219f9d0b1916af4.zip frameworks_base-88e03a97366d08fc69d852cf2219f9d0b1916af4.tar.gz frameworks_base-88e03a97366d08fc69d852cf2219f9d0b1916af4.tar.bz2 |
Add ability to run tests restricted to given annotation.
And ability to exclude tests with given annotation.
Also fix class cast compile warning in emma output method.
Bug 2239240
Change-Id: I56273a51a8c58a690680bdb612615fab69e6e13f
Diffstat (limited to 'test-runner/tests')
-rw-r--r-- | test-runner/tests/src/android/test/InstrumentationTestRunnerTest.java | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/test-runner/tests/src/android/test/InstrumentationTestRunnerTest.java b/test-runner/tests/src/android/test/InstrumentationTestRunnerTest.java index d9afd54..6db72ad 100644 --- a/test-runner/tests/src/android/test/InstrumentationTestRunnerTest.java +++ b/test-runner/tests/src/android/test/InstrumentationTestRunnerTest.java @@ -109,6 +109,33 @@ public class InstrumentationTestRunnerTest extends TestCase { assertTrue(mStubAndroidTestRunner.isRun()); } + /** + * Test that the -e {@link InstrumentationTestRunner.ARGUMENT_ANNOTATION} parameter properly + * selects tests. + */ + public void testAnnotationParameter() throws Exception { + String expectedTestClassName = AnnotationTest.class.getName(); + Bundle args = new Bundle(); + args.putString(InstrumentationTestRunner.ARGUMENT_TEST_CLASS, expectedTestClassName); + args.putString(InstrumentationTestRunner.ARGUMENT_ANNOTATION, FlakyTest.class.getName()); + mInstrumentationTestRunner.onCreate(args); + assertTestRunnerCalledWithExpectedParameters(expectedTestClassName, "testAnnotated"); + } + + /** + * Test that the -e {@link InstrumentationTestRunner.ARGUMENT_NOT_ANNOTATION} parameter + * properly excludes tests. + */ + public void testNotAnnotationParameter() throws Exception { + String expectedTestClassName = AnnotationTest.class.getName(); + Bundle args = new Bundle(); + args.putString(InstrumentationTestRunner.ARGUMENT_TEST_CLASS, expectedTestClassName); + args.putString(InstrumentationTestRunner.ARGUMENT_NOT_ANNOTATION, + FlakyTest.class.getName()); + mInstrumentationTestRunner.onCreate(args); + assertTestRunnerCalledWithExpectedParameters(expectedTestClassName, "testNotAnnotated"); + } + private void assertContentsInOrder(List<TestDescriptor> actual, TestDescriptor... source) { TestDescriptor[] clonedSource = source.clone(); assertEquals("Unexpected number of items.", clonedSource.length, actual.size()); @@ -269,4 +296,17 @@ public class InstrumentationTestRunnerTest extends TestCase { } } + + /** + * Annotated test used for validation. + */ + public static class AnnotationTest extends TestCase { + + public void testNotAnnotated() throws Exception { + } + + @FlakyTest + public void testAnnotated() throws Exception { + } + } } |