Skip to content

Commit d460586

Browse files
committed
Fix review comments
1 parent 348f5a0 commit d460586

2 files changed

Lines changed: 14 additions & 9 deletions

File tree

src/main/java/com/epam/reportportal/cucumber/ScenarioReporter.java

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,22 @@ public class ScenarioReporter implements ConcurrentEventListener {
8888
private static final String TEST_CASE_ID_PREFIX = "@tc_id:";
8989
private static final String ERROR_FORMAT = "Error:\n%s";
9090

91-
private static final Class<?> TESTNG_LISTENER_CLASS;
91+
private static final Method IS_RETRY_METHOD;
9292

9393
static {
9494
Class<?> testNgListenerClass = null;
9595
try {
9696
testNgListenerClass = Class.forName("com.epam.reportportal.cucumber.testng.TestNgRetriesListener");
9797
} catch (Exception ignore) {
98-
9998
}
100-
TESTNG_LISTENER_CLASS = testNgListenerClass;
99+
Method isRetry = null;
100+
if (testNgListenerClass != null) {
101+
try {
102+
isRetry = testNgListenerClass.getMethod("isRetry", String.class);
103+
} catch (NoSuchMethodException ignore) {
104+
}
105+
}
106+
IS_RETRY_METHOD = isRetry;
101107
}
102108

103109
private final Map<URI, FeatureContext> featureContextMap = new ConcurrentHashMap<>();
@@ -1011,14 +1017,13 @@ protected void beforeScenario(@Nonnull TestCase scenario) {
10111017
// If it's a ScenarioOutline use Example's line number as code reference to detach one Test Item from another
10121018
StartTestItemRQ startTestItemRQ = buildStartScenarioRequest(scenario);
10131019
boolean testNgRetry = false;
1014-
if (TESTNG_LISTENER_CLASS != null) {
1020+
if (IS_RETRY_METHOD != null) {
10151021
try {
1016-
Method isRetry = TESTNG_LISTENER_CLASS.getMethod("isRetry", String.class);
1017-
testNgRetry = (Boolean) isRetry.invoke(
1022+
testNgRetry = Boolean.TRUE.equals(IS_RETRY_METHOD.invoke(
10181023
null,
10191024
scenario.getUri() + KEY_VALUE_SEPARATOR + scenario.getLocation().getLine()
1020-
);
1021-
} catch (NoSuchMethodException | SecurityException | InvocationTargetException | IllegalAccessException ignore) {
1025+
));
1026+
} catch (SecurityException | InvocationTargetException | IllegalAccessException ignore) {
10221027
}
10231028
}
10241029
if (testNgRetry) {

src/test/java/com/epam/reportportal/cucumber/ParameterTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public void verify_agent_creates_correct_step_names() {
128128
});
129129
}
130130

131-
List<Map<String, String>> EXPECTED_PARAMETERS = Arrays.asList(
131+
private static final List<Map<String, String>> EXPECTED_PARAMETERS = Arrays.asList(
132132
Map.of("str", "\"first\"", "parameters", "123"),
133133
Map.of("str", "\"second\"", "parameters", "12345"),
134134
Map.of("str", "\"third\"", "parameters", "12345678")

0 commit comments

Comments
 (0)