From 39d9aef13dbc9acf2be30b3db734c561f97626a4 Mon Sep 17 00:00:00 2001 From: Jake Slack Date: Fri, 4 Apr 2014 11:51:12 -0700 Subject: Resetting test state after a failed flaky test. Currently, we do not tear down and re-setup a flaky test on the next attempt. This means, if part of the test puts the app in some state that is not expected at the beginning of the test, the test will fail. Change-Id: Ie1caeb9505c490536add60da88409b66b939c4cf --- src/com/google/android/droiddriver/helpers/BaseDroidDriverTest.java | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/com/google/android/droiddriver/helpers/BaseDroidDriverTest.java b/src/com/google/android/droiddriver/helpers/BaseDroidDriverTest.java index 3725bbd..3ce5030 100644 --- a/src/com/google/android/droiddriver/helpers/BaseDroidDriverTest.java +++ b/src/com/google/android/droiddriver/helpers/BaseDroidDriverTest.java @@ -191,6 +191,8 @@ public abstract class BaseDroidDriverTest extends /** * Overrides super.runTest() to fail fast when the test is annotated as * FlakyTest and we should skip remaining tests (the failure is fatal). + * When a flaky test is re-run, tearDown() and setUp() are called first in order + * to reset the test's state. */ @Override protected void runTest() throws Throwable { @@ -219,6 +221,9 @@ public abstract class BaseDroidDriverTest extends for (int runCount = 0; runCount < tolerance; runCount++) { if (runCount > 0) { Logs.logfmt(Log.INFO, "Running %s round %d of %d attempts", fName, runCount + 1, tolerance); + // We are re-attempting a test, so reset all state. + tearDown(); + setUp(); } try { -- cgit v1.2.3