diff --git a/src/main/java/com/zebrunner/agent/testng/adapter/TestNGAdapter.java b/src/main/java/com/zebrunner/agent/testng/adapter/TestNGAdapter.java index 4022962..f9a6212 100644 --- a/src/main/java/com/zebrunner/agent/testng/adapter/TestNGAdapter.java +++ b/src/main/java/com/zebrunner/agent/testng/adapter/TestNGAdapter.java @@ -133,8 +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) { + if (RunContextHolder.isRerun()) { ITestContext context = testResult.getTestContext(); Object[] parameters = testResult.getParameters(); @@ -295,6 +294,10 @@ public void registerAfterTestFinish() { registrar.registerAfterTestFinish(); } + public void clearConfigurationLogs() { + registrar.clearConfigurationLogs(); + } + private TestInvocationContext buildTestInvocationContext(ITestNGMethod testMethod, int dataProviderIndex, Object[] parameters, int invocationIndex) { String displayName = null; Test testAnnotation = testMethod.getConstructorOrMethod() diff --git a/src/main/java/com/zebrunner/agent/testng/listener/RetryService.java b/src/main/java/com/zebrunner/agent/testng/listener/RetryService.java index b0fa06f..7db8a0d 100644 --- a/src/main/java/com/zebrunner/agent/testng/listener/RetryService.java +++ b/src/main/java/com/zebrunner/agent/testng/listener/RetryService.java @@ -90,10 +90,6 @@ 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) .map(retryItemContext -> retryItemContext.get(method.getParameterInvocationCount())) diff --git a/src/main/java/com/zebrunner/agent/testng/listener/TestRunListener.java b/src/main/java/com/zebrunner/agent/testng/listener/TestRunListener.java index 90ba2e3..82e66fc 100644 --- a/src/main/java/com/zebrunner/agent/testng/listener/TestRunListener.java +++ b/src/main/java/com/zebrunner/agent/testng/listener/TestRunListener.java @@ -95,12 +95,6 @@ public void beforeConfiguration(ITestResult tr, ITestNGMethod tm) { if (testMethod instanceof ConfigurationMethod) { ConfigurationMethod configurationMethod = (ConfigurationMethod) testMethod; - //unable to register test for before suite because all tests reported to the single test - - if (configurationMethod.isBeforeClassConfiguration()) { - adapter.registerHeadlessTestStart(tr, tm); - } - if (configurationMethod.isBeforeMethodConfiguration()) { adapter.registerHeadlessTestStart(tr, tm); } @@ -130,6 +124,10 @@ private void registerFinishOfAfterMethod(ITestResult testResult) { if (testMethod instanceof ConfigurationMethod) { ConfigurationMethod configurationMethod = (ConfigurationMethod) testMethod; + if(configurationMethod.isAfterClassConfiguration() || + configurationMethod.isAfterTestConfiguration()) { + adapter.clearConfigurationLogs(); + } if (configurationMethod.isAfterMethodConfiguration()) { adapter.registerAfterTestFinish(); }