diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2017-05-28 07:22:26 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2017-05-28 07:22:26 +0000 |
commit | 00048e0a8080d5d680548a815d43bb13075211df (patch) | |
tree | 6262b22b124f4150e90cc44dd5a728d34ec42f9c | |
parent | 4f663bf7d4fc1fa6de5b833d60fabdf729a9bf4d (diff) | |
parent | d3a59810693f3150d25699d6505a36b246d9191d (diff) | |
download | tradefederation-00048e0a8080d5d680548a815d43bb13075211df.tar.gz |
release-request-fca2b5ac-03eb-4055-a549-b4fc2b292b64-for-git_oc-release-4049993 snap-temp-L04900000068539456
Change-Id: I644142c49dd5eaa2def6c14cee94d526d97c577c
-rw-r--r-- | Android.mk | 4 | ||||
-rw-r--r-- | src/com/android/tradefed/result/JUnit4ResultForwarder.java | 4 | ||||
-rw-r--r-- | tests/src/com/android/tradefed/testtype/HostTestTest.java | 51 |
3 files changed, 57 insertions, 2 deletions
diff --git a/Android.mk b/Android.mk index b245de0fb..b70b1e0a9 100644 --- a/Android.mk +++ b/Android.mk @@ -111,7 +111,7 @@ include $(CLEAR_VARS) # Note that this is incompatible with `make dist`. If you want to make # the distribution, you must run `tapas` with the individual target names. .PHONY: tradefed-all -tradefed-all: tradefed tradefed-tests tf-prod-tests tf-prod-metatests tradefed_win script_help verify tradefed-contrib tf-contrib-prod-tests +tradefed-all: tradefed tradefed-tests tf-prod-tests tf-prod-metatests tradefed_win script_help verify tradefed-contrib # ==================================== include $(CLEAR_VARS) @@ -129,7 +129,7 @@ include $(call all-makefiles-under,$(LOCAL_PATH)) # Zip up the built files and dist it as tradefed.zip ifneq (,$(filter tradefed tradefed-all, $(TARGET_BUILD_APPS))) -tradefed_dist_host_jars := tradefed tradefed-tests tf-prod-tests emmalib jack-jacoco-reporter loganalysis loganalysis-tests tf-remote-client tradefed-contrib tf-contrib-prod-tests +tradefed_dist_host_jars := tradefed tradefed-tests tf-prod-tests emmalib jack-jacoco-reporter loganalysis loganalysis-tests tf-remote-client tradefed-contrib tradefed_dist_host_jar_files := $(foreach m, $(tradefed_dist_host_jars), $(HOST_OUT_JAVA_LIBRARIES)/$(m).jar) tradefed_dist_host_exes := tradefed.sh tradefed_win.bat script_help.sh verify.sh run_tf_cmd.sh diff --git a/src/com/android/tradefed/result/JUnit4ResultForwarder.java b/src/com/android/tradefed/result/JUnit4ResultForwarder.java index 2ee53e29a..f3cfd52e0 100644 --- a/src/com/android/tradefed/result/JUnit4ResultForwarder.java +++ b/src/com/android/tradefed/result/JUnit4ResultForwarder.java @@ -68,6 +68,10 @@ public class JUnit4ResultForwarder extends RunListener { public void testIgnored(Description description) throws Exception { TestIdentifier testid = new TestIdentifier(description.getClassName(), description.getMethodName()); + // We complete the event life cycle since JUnit4 fireIgnored is not within fireTestStarted + // and fireTestEnded. + mListener.testStarted(testid); mListener.testIgnored(testid); + mListener.testEnded(testid, Collections.emptyMap()); } } diff --git a/tests/src/com/android/tradefed/testtype/HostTestTest.java b/tests/src/com/android/tradefed/testtype/HostTestTest.java index 55c929730..fd8021d9c 100644 --- a/tests/src/com/android/tradefed/testtype/HostTestTest.java +++ b/tests/src/com/android/tradefed/testtype/HostTestTest.java @@ -29,6 +29,7 @@ import junit.framework.TestSuite; import org.easymock.Capture; import org.easymock.EasyMock; import org.junit.Before; +import org.junit.Ignore; import org.junit.runner.RunWith; import org.junit.runners.Suite.SuiteClasses; @@ -121,6 +122,34 @@ public class HostTestTest extends TestCase { } } + /** + * Test class, we have to annotate with full org.junit.Test to avoid name collision in import. + * And with one test marked as Ignored + */ + @RunWith(DeviceJUnit4ClassRunner.class) + public static class Junit4TestClassWithIgnore implements IDeviceTest { + private ITestDevice mDevice; + + public Junit4TestClassWithIgnore() {} + + @org.junit.Test + public void testPass5() {} + + @Ignore + @org.junit.Test + public void testPass6() {} + + @Override + public void setDevice(ITestDevice device) { + mDevice = device; + } + + @Override + public ITestDevice getDevice() { + return mDevice; + } + } + @RunWith(DeviceSuite.class) @SuiteClasses({ Junit4TestClass.class, @@ -738,6 +767,28 @@ public class HostTestTest extends TestCase { } /** + * Test for {@link HostTest#run(ITestInvocationListener)}, for test with Junit4 style and + * handling of @Ignored. + */ + public void testRun_junit4style_ignored() throws Exception { + mHostTest.setClassName(Junit4TestClassWithIgnore.class.getName()); + TestIdentifier test1 = + new TestIdentifier(Junit4TestClassWithIgnore.class.getName(), "testPass5"); + TestIdentifier test2 = + new TestIdentifier(Junit4TestClassWithIgnore.class.getName(), "testPass6"); + mListener.testRunStarted((String) EasyMock.anyObject(), EasyMock.eq(2)); + mListener.testStarted(EasyMock.eq(test1)); + mListener.testEnded(EasyMock.eq(test1), (Map<String, String>) EasyMock.anyObject()); + mListener.testStarted(EasyMock.eq(test2)); + mListener.testIgnored(EasyMock.eq(test2)); + mListener.testEnded(EasyMock.eq(test2), (Map<String, String>) EasyMock.anyObject()); + mListener.testRunEnded(EasyMock.anyLong(), (Map<String, String>) EasyMock.anyObject()); + EasyMock.replay(mListener); + mHostTest.run(mListener); + EasyMock.verify(mListener); + } + + /** * Test for {@link HostTest#run(ITestInvocationListener)}, for test with Junit4 style and with * method filtering. Only run the expected method. */ |