Skip to content

Commit 78c954e

Browse files
author
Sergey Brenko
authored
Merge pull request #61 from zebrunner/refactor
reuse if for isRetryFinished
2 parents a824a5b + 3e4a91d commit 78c954e

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/main/java/com/zebrunner/agent/testng/adapter/TestNGAdapter.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ private TestInvocationContext buildTestStartInvocationContext(ITestResult testRe
133133
}
134134

135135
private void setZebrunnerTestIdOnRerun(ITestResult testResult, ITestNGMethod testMethod, TestStartDescriptor testStartDescriptor) {
136+
// testMethod is not available for BeforeClass configuration method, so we just skip this logic in such case
136137
if (RunContextHolder.isRerun() && testMethod != null) {
137138
ITestContext context = testResult.getTestContext();
138139
Object[] parameters = testResult.getParameters();

src/main/java/com/zebrunner/agent/testng/listener/RetryService.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
import java.util.Arrays;
1414
import java.util.Map;
15-
import java.util.Objects;
1615
import java.util.Optional;
1716
import java.util.concurrent.ConcurrentHashMap;
1817
import java.util.stream.Collectors;
@@ -91,9 +90,12 @@ private static RetryItemContext getOrInitRetryItemContext(ITestNGMethod method,
9190
}
9291

9392
public static boolean isRetryFinished(ITestNGMethod method, ITestContext context) {
93+
if (method == null) {
94+
// method is not available for BeforeClass configuration method, so we just return true here
95+
return true;
96+
}
9497
return getRetryContext(context)
9598
.map(RetryContext::getRetryItemContexts)
96-
.filter(d -> method != null)
9799
.map(retryItemContext -> retryItemContext.get(method.getParameterInvocationCount()))
98100
.map(RetryItemContext::isFinished)
99101
.orElse(true);

0 commit comments

Comments
 (0)