Skip to content

Commit

Permalink
Merge pull request serenity-bdd#1998 from scormaq/master
Browse files Browse the repository at this point in the history
fix: issue 1997 - report correct number of junit retries
  • Loading branch information
wakaleo authored Mar 12, 2020
2 parents 1b8027b + 0be94f8 commit 0d5f09c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -218,14 +218,14 @@ public void cancelPreviousTest() {
}
}

public void lastTestPassedAfterRetries(int remainingTries, List<String> failureMessages, TestFailureCause testfailureCause) {
public void lastTestPassedAfterRetries(int attemptNum, List<String> failureMessages, TestFailureCause testfailureCause) {
if (latestTestOutcome().isPresent()) {
latestTestOutcome().get().recordStep(
TestStep.forStepCalled("UNSTABLE TEST:\n" + failureHistoryFor(failureMessages))
.withResult(UNDEFINED));
// .withResult(TestResult.IGNORED));

latestTestOutcome().get().addTag(TestTag.withName("Retries: " + (remainingTries - 1)).andType("unstable test"));
latestTestOutcome().get().addTag(TestTag.withName("Retries: " + attemptNum).andType("unstable test"));
latestTestOutcome().get().setFlakyTestFailureCause(testfailureCause);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,14 +446,15 @@ private void retryAtMost(int remainingTries,
RerunTest rerunTest) {
if (remainingTries <= 0) { return; }

logger.info(rerunTest.toString() + ": attempt " + (maxRetries() - remainingTries));
int attemptNum = maxRetries() - remainingTries + 1;
logger.info(rerunTest.toString() + ": attempt " + attemptNum);
StepEventBus.getEventBus().cancelPreviousTest();
rerunTest.perform();

if (failureDetectingStepListener.lastTestFailed()) {
retryAtMost(remainingTries - 1, rerunTest);
} else {
StepEventBus.getEventBus().lastTestPassedAfterRetries(remainingTries,
StepEventBus.getEventBus().lastTestPassedAfterRetries(attemptNum,
failureDetectingStepListener.getFailureMessages(),failureDetectingStepListener.getTestFailureCause());
}
}
Expand Down

0 comments on commit 0d5f09c

Please sign in to comment.