Resolve carry-over state issue in TestServerRule

The TestServerRule object is shared between retries in the same test,
so the testServer object constructed in TestServerRule's constructor
will be shared as well. This should be the reason why the test retry
carries over some state. (The log in the test proves that the
testServer object is shared because it listens to the same port in
all retries, which should not happen if its constructor is invoked
every time. You can find multiple "TestServerRule is listening on:
[]in this test
[]

So, this CL delayed the construction to rule.before() method which is
invoked before every retry.(You can see each retry has a test server
listening to different port and the error is "It differed by <16> pixels."
for all attempts instead of not clickable button []

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=246904446
This commit is contained in:
shicong 2019-05-06 15:03:42 -07:00 committed by jianglai
parent 7577fbdbd4
commit 5e2a20cdcf
2 changed files with 25 additions and 12 deletions

View file

@ -153,7 +153,7 @@ public class RepeatableRunner extends BlockJUnit4ClassRunner {
} catch (Throwable e) {
numFailure++;
lastException = e;
logger.atWarning().log(
logger.atWarning().withCause(e).log(
"[%s] Attempt %d of %d failed!\n", method.getName(), attempt, MAX_ATTEMPTS);
}
}