diff options
author | 2017-06-22 14:39:08 +0000 | |
---|---|---|
committer | 2017-06-22 14:39:08 +0000 | |
commit | e211119fea8e01e573ecde57ced2e9bf8dfbf65e (patch) | |
tree | 9e2e6ff8e81cb56b7d74c25af9e031c51fd6f2a6 | |
parent | 78def25969de6aa4af000e6387618fb2c5b10490 (diff) | |
parent | 34dc5a58b33811b55263629c500966d44978288b (diff) |
Merge "Ensure that android.test tests pass" am: 156775fea8
am: 34dc5a58b3
Change-Id: I546ea542d0781f825e131eb94bc54e22adadfc4e
6 files changed, 57 insertions, 7 deletions
diff --git a/test-runner/tests/Android.mk b/test-runner/tests/Android.mk index 68fd6621718c..cc9b01d18fa6 100644 --- a/test-runner/tests/Android.mk +++ b/test-runner/tests/Android.mk @@ -16,6 +16,13 @@ LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) # We only want this apk build for tests. +# +# Run the tests using the following commands: +# adb -r install ${ANDROID_PRODUCT_OUT}/data/app/FrameworkTestRunnerTests/FrameworkTestRunnerTests.apk +# adb shell am instrument \ + -e notAnnotation android.test.suitebuilder.examples.error.RunAsPartOfSeparateTest \ + -w com.android.frameworks.testrunner.tests/android.test.InstrumentationTestRunner +# LOCAL_MODULE_TAGS := tests LOCAL_JAVA_LIBRARIES := android.test.runner diff --git a/test-runner/tests/src/android/test/TestCaseUtilTest.java b/test-runner/tests/src/android/test/TestCaseUtilTest.java index bc6fa9200d1b..9d12eafcd34f 100644 --- a/test-runner/tests/src/android/test/TestCaseUtilTest.java +++ b/test-runner/tests/src/android/test/TestCaseUtilTest.java @@ -29,9 +29,7 @@ public class TestCaseUtilTest extends TestCase { List<String> testCaseNames = TestCaseUtil.getTestCaseNames(testSuite, false); - assertEquals(2, testCaseNames.size()); - assertTrue(testCaseNames.get(0).endsWith("OneTestTestCase")); - assertTrue(testCaseNames.get(1).endsWith("OneTestTestSuite")); + assertEquals(0, testCaseNames.size()); } public void testGetTestCaseNamesForTestCaseWithSuiteMethod() throws Exception { diff --git a/test-runner/tests/src/android/test/suitebuilder/TestSuiteBuilderTest.java b/test-runner/tests/src/android/test/suitebuilder/TestSuiteBuilderTest.java index 293c8133eb95..a2e51a197a98 100644 --- a/test-runner/tests/src/android/test/suitebuilder/TestSuiteBuilderTest.java +++ b/test-runner/tests/src/android/test/suitebuilder/TestSuiteBuilderTest.java @@ -135,10 +135,23 @@ public class TestSuiteBuilderTest extends TestCase { TestSuite testSuite = new OuterTest().buildTestsUnderHereRecursively(); assertContentsInOrder(getTestCaseNames(testSuite), - "testOuter", "testErrorOne", "testErrorTwo", "testFailOne", "testFailTwo", - "testInstrumentation", "testLevel1", "testLevel2", "testAnotherOne", - "testSimpleOne", "testSimpleTwo", "testNonSmoke", "testSmoke", "testSubclass", - "testSuperclass", "testUnSuppressedMethod"); + "testOuter", + "testPublicConstructor", + "testErrorOne", + "testErrorTwo", + "testFailOne", + "testFailTwo", + "testInstrumentation", + "testLevel1", + "testLevel2", + "testAnotherOne", + "testSimpleOne", + "testSimpleTwo", + "testNonSmoke", + "testSmoke", + "testSubclass", + "testSuperclass", + "testUnSuppressedMethod"); } private void assertContentsInOrder(List<String> actual, String... source) { diff --git a/test-runner/tests/src/android/test/suitebuilder/examples/error/ErrorTest.java b/test-runner/tests/src/android/test/suitebuilder/examples/error/ErrorTest.java index f1f6113e86d2..ddf5dd16ece9 100644 --- a/test-runner/tests/src/android/test/suitebuilder/examples/error/ErrorTest.java +++ b/test-runner/tests/src/android/test/suitebuilder/examples/error/ErrorTest.java @@ -18,6 +18,7 @@ package android.test.suitebuilder.examples.error; import junit.framework.TestCase; +@RunAsPartOfSeparateTest public class ErrorTest extends TestCase { public void testErrorOne() throws Exception { diff --git a/test-runner/tests/src/android/test/suitebuilder/examples/error/FailingTest.java b/test-runner/tests/src/android/test/suitebuilder/examples/error/FailingTest.java index 428fd23b819d..0170b2f6cc70 100644 --- a/test-runner/tests/src/android/test/suitebuilder/examples/error/FailingTest.java +++ b/test-runner/tests/src/android/test/suitebuilder/examples/error/FailingTest.java @@ -18,6 +18,7 @@ package android.test.suitebuilder.examples.error; import junit.framework.TestCase; +@RunAsPartOfSeparateTest public class FailingTest extends TestCase { public void testFailOne() throws Exception { diff --git a/test-runner/tests/src/android/test/suitebuilder/examples/error/RunAsPartOfSeparateTest.java b/test-runner/tests/src/android/test/suitebuilder/examples/error/RunAsPartOfSeparateTest.java new file mode 100644 index 000000000000..2b3a2528a39a --- /dev/null +++ b/test-runner/tests/src/android/test/suitebuilder/examples/error/RunAsPartOfSeparateTest.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2017 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package android.test.suitebuilder.examples.error; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Annotation that marks tests that should only be run as part of a separate test and not on their + * own. + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +public @interface RunAsPartOfSeparateTest { +} |