Skip to content

Commit

Permalink
Merge pull request #61 from zebrunner/refactor
Browse files Browse the repository at this point in the history
reuse if for isRetryFinished
  • Loading branch information
SergeyBrenko authored Jun 26, 2024
2 parents a824a5b + 3e4a91d commit 78c954e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ private TestInvocationContext buildTestStartInvocationContext(ITestResult testRe
}

private void setZebrunnerTestIdOnRerun(ITestResult testResult, ITestNGMethod testMethod, TestStartDescriptor testStartDescriptor) {
// testMethod is not available for BeforeClass configuration method, so we just skip this logic in such case
if (RunContextHolder.isRerun() && testMethod != null) {
ITestContext context = testResult.getTestContext();
Object[] parameters = testResult.getParameters();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

import java.util.Arrays;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -91,9 +90,12 @@ private static RetryItemContext getOrInitRetryItemContext(ITestNGMethod method,
}

public static boolean isRetryFinished(ITestNGMethod method, ITestContext context) {
if (method == null) {
// method is not available for BeforeClass configuration method, so we just return true here
return true;
}
return getRetryContext(context)
.map(RetryContext::getRetryItemContexts)
.filter(d -> method != null)
.map(retryItemContext -> retryItemContext.get(method.getParameterInvocationCount()))
.map(RetryItemContext::isFinished)
.orElse(true);
Expand Down

0 comments on commit 78c954e

Please sign in to comment.