From a108c07ce2a6ab11b1e5cc798b6c9c7579c0986f Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Fri, 12 Apr 2024 11:58:40 +0300 Subject: [PATCH 1/8] Action version update --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 982e4e4..4703654 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -56,7 +56,7 @@ jobs: java-version: '11' - name: Setup git credentials - uses: oleksiyrudenko/gha-git-credentials@v2.1.1 + uses: oleksiyrudenko/gha-git-credentials@v2-latest with: name: 'reportportal.io' email: 'support@reportportal.io' From c11de4c5b228e6b0b9b64ca30b28872c3c56fed5 Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Mon, 15 Apr 2024 17:55:18 +0300 Subject: [PATCH 2/8] Format of last error log of test in item description was updated --- CHANGELOG.md | 3 +++ build.gradle | 2 +- .../com/epam/reportportal/testng/TestNGService.java | 11 ++++++----- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eeec498..de2b4cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # Changelog ## [Unreleased] +### Changed +- Client version updated on [5.2.14](https://github.com/reportportal/client-java/releases/tag/5.2.14), by @HardNorth +- Format of last error log of test in item description was updated, by @HardNorth ## [5.4.2] ### Added diff --git a/build.gradle b/build.gradle index 1ed89e7..1db06c1 100644 --- a/build.gradle +++ b/build.gradle @@ -39,7 +39,7 @@ repositories { } dependencies { - api 'com.epam.reportportal:client-java:5.2.13' + api 'com.epam.reportportal:client-java:5.2.14' compileOnly "org.testng:testng:${testng_version}" implementation 'org.slf4j:slf4j-api:2.0.4' diff --git a/src/main/java/com/epam/reportportal/testng/TestNGService.java b/src/main/java/com/epam/reportportal/testng/TestNGService.java index 2fba44a..2df7323 100644 --- a/src/main/java/com/epam/reportportal/testng/TestNGService.java +++ b/src/main/java/com/epam/reportportal/testng/TestNGService.java @@ -31,6 +31,7 @@ import com.epam.reportportal.utils.MemoizingSupplier; import com.epam.reportportal.utils.ParameterUtils; import com.epam.reportportal.utils.TestCaseIdUtils; +import com.epam.reportportal.utils.markdown.MarkdownUtils; import com.epam.reportportal.utils.properties.SystemAttributesExtractor; import com.epam.ta.reportportal.ws.model.*; import com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ; @@ -95,7 +96,7 @@ public class TestNGService implements ITestNGService { public static final String RP_RETRY = "rp_retry"; public static final String RP_METHOD_TYPE = "rp_method_type"; public static final String NULL_VALUE = "NULL"; - public static final String DESCRIPTION_ERROR_FORMAT = "%s\nError: \n%s"; + public static final String DESCRIPTION_ERROR_FORMAT = "Error: \n%s"; public static final TestItemTree ITEM_TREE = new TestItemTree(); private final Map, FinishTestItemRQ>>> BEFORE_METHOD_TRACKER = new ConcurrentHashMap<>(); @@ -809,9 +810,9 @@ Maybe getConfigParent(ITestResult testResult, TestMethodType type) { * @return Test/Step Description being sent to ReportPortal */ private String getLogMessage(ITestResult testResult) { - return String.format(DESCRIPTION_ERROR_FORMAT, - createStepDescription(testResult), - ExceptionUtils.getStackTrace(testResult.getThrowable())) - .trim(); + return MarkdownUtils.asTwoParts( + createStepDescription(testResult), + String.format(DESCRIPTION_ERROR_FORMAT, ExceptionUtils.getStackTrace(testResult.getThrowable())).trim() + ); } } From a9c6848c730d828445b1cf53ade7ab49c8490336 Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Wed, 9 Oct 2024 22:28:25 +0300 Subject: [PATCH 3/8] Update TestNG dependency --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 500ed82..45446ad 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ description=TestNG integration for ReportPortal junit5_version=5.6.3 junit5_runner_version=1.6.3 mockito_version=3.3.3 -testng_version=7.9.0 +testng_version=7.10.2 scripts_url=https://raw.githubusercontent.com/reportportal/gradle-scripts scripts_branch=master excludeTests= From f9788d14e99935e96e11c3a5b825c83c675176f8 Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Wed, 9 Oct 2024 23:11:37 +0300 Subject: [PATCH 4/8] Fix tests --- .../com/epam/reportportal/testng/TestNGService.java | 8 ++++---- .../reportportal/testng/TestDescriptionFailedTest.java | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/epam/reportportal/testng/TestNGService.java b/src/main/java/com/epam/reportportal/testng/TestNGService.java index 2df7323..5953e46 100644 --- a/src/main/java/com/epam/reportportal/testng/TestNGService.java +++ b/src/main/java/com/epam/reportportal/testng/TestNGService.java @@ -38,6 +38,7 @@ import com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ; import com.epam.ta.reportportal.ws.model.log.SaveLogRQ; import io.reactivex.Maybe; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.exception.ExceptionUtils; import org.apache.commons.lang3.tuple.Pair; import org.testng.*; @@ -810,9 +811,8 @@ Maybe getConfigParent(ITestResult testResult, TestMethodType type) { * @return Test/Step Description being sent to ReportPortal */ private String getLogMessage(ITestResult testResult) { - return MarkdownUtils.asTwoParts( - createStepDescription(testResult), - String.format(DESCRIPTION_ERROR_FORMAT, ExceptionUtils.getStackTrace(testResult.getThrowable())).trim() - ); + String error = String.format(DESCRIPTION_ERROR_FORMAT, ExceptionUtils.getStackTrace(testResult.getThrowable())).trim(); + return ofNullable(createStepDescription(testResult)).filter(StringUtils::isNotBlank) + .map(description -> MarkdownUtils.asTwoParts(description, error)).orElse(error); } } diff --git a/src/test/java/com/epam/reportportal/testng/TestDescriptionFailedTest.java b/src/test/java/com/epam/reportportal/testng/TestDescriptionFailedTest.java index 6b5007f..48a457c 100644 --- a/src/test/java/com/epam/reportportal/testng/TestDescriptionFailedTest.java +++ b/src/test/java/com/epam/reportportal/testng/TestDescriptionFailedTest.java @@ -24,6 +24,7 @@ import com.epam.reportportal.service.ReportPortalClient; import com.epam.reportportal.testng.integration.feature.description.DescriptionFailedTest; import com.epam.reportportal.utils.MemoizingSupplier; +import com.epam.reportportal.utils.markdown.MarkdownUtils; import com.epam.ta.reportportal.ws.model.FinishTestItemRQ; import com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ; import java.util.Calendar; @@ -67,11 +68,10 @@ private static Launch getLaunch(ListenerParameters parameters) { private final String testClassUuid = namedUuid("class"); private final String assertionError = "java.lang.AssertionError: " + ASSERT_ERROR; private final String noSuchElementException = "java.util.NoSuchElementException: " + NO_SUCH_ELEMENT_EXCEPTION; - private final String empty = ""; - private final String testDescriptionTestAssertErrorMessage = String.format(DESCRIPTION_ERROR_FORMAT, TEST_DESCRIPTION, assertionError); - private final String testDescriptionTestExceptionMessage = String.format(DESCRIPTION_ERROR_FORMAT, TEST_DESCRIPTION, noSuchElementException); - private final String testWithoutDescriptionTestAssertErrorMessage = String.format(DESCRIPTION_ERROR_FORMAT, empty, assertionError).trim(); - private final String testWithoutDescriptionTestExceptionMessage = String.format(DESCRIPTION_ERROR_FORMAT, empty, noSuchElementException).trim(); + private final String testDescriptionTestAssertErrorMessage = MarkdownUtils.asTwoParts(TEST_DESCRIPTION, String.format(DESCRIPTION_ERROR_FORMAT, assertionError)); + private final String testDescriptionTestExceptionMessage = MarkdownUtils.asTwoParts(TEST_DESCRIPTION, String.format(DESCRIPTION_ERROR_FORMAT, noSuchElementException)); + private final String testWithoutDescriptionTestAssertErrorMessage = String.format(DESCRIPTION_ERROR_FORMAT, assertionError).trim(); + private final String testWithoutDescriptionTestExceptionMessage = String.format(DESCRIPTION_ERROR_FORMAT, noSuchElementException).trim(); @Mock private ReportPortalClient client; From 12187baa96c26a76bbaf6b97e4114d6c19397129 Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Fri, 11 Oct 2024 09:38:38 +0300 Subject: [PATCH 5/8] Remove code references on Test level to fix reruns --- .../reportportal/testng/TestNGService.java | 43 +++++++++---------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/epam/reportportal/testng/TestNGService.java b/src/main/java/com/epam/reportportal/testng/TestNGService.java index 5953e46..77431c3 100644 --- a/src/main/java/com/epam/reportportal/testng/TestNGService.java +++ b/src/main/java/com/epam/reportportal/testng/TestNGService.java @@ -75,16 +75,14 @@ * TestNG service implements operations for interaction ReportPortal */ public class TestNGService implements ITestNGService { - private static final Set BEFORE_METHODS = Stream.of( - TestMethodType.BEFORE_TEST, + private static final Set BEFORE_METHODS = Stream.of(TestMethodType.BEFORE_TEST, TestMethodType.BEFORE_SUITE, TestMethodType.BEFORE_GROUPS, TestMethodType.BEFORE_CLASS, TestMethodType.BEFORE_METHOD ).collect(Collectors.toSet()); private static final String AGENT_PROPERTIES_FILE = "agent.properties"; - private static final Set TESTNG_INVOKERS = Stream.of( - "org.testng.internal.TestInvoker", + private static final Set TESTNG_INVOKERS = Stream.of("org.testng.internal.TestInvoker", "org.testng.internal.invokers.TestInvoker" ).collect(Collectors.toSet()); private static final Predicate IS_RETRY_ELEMENT = e -> TESTNG_INVOKERS.contains(e.getClassName()) @@ -284,7 +282,7 @@ protected StartTestItemRQ buildStartConfigurationRq(@Nonnull ITestResult testRes @Override public void startConfiguration(ITestResult testResult) { - if(ofNullable(getAttribute(testResult, RP_ID)).isPresent()) { + if (ofNullable(getAttribute(testResult, RP_ID)).isPresent()) { // Already started, E.G. SkipException is thrown return; } @@ -471,13 +469,11 @@ public void finishTestMethod(ItemStatus status, ITestResult testResult) { if (ItemStatus.FAILED == status && (TestMethodType.BEFORE_METHOD == type || TestMethodType.BEFORE_CLASS == type)) { SKIPPED_STATUS_TRACKER.put(instance, Boolean.TRUE); } - if (ItemStatus.SKIPPED == status - && (SKIPPED_STATUS_TRACKER.containsKey(instance) - || (TestMethodType.BEFORE_METHOD == type && getAttribute(testResult, RP_RETRY) != null)) - ) { + if (ItemStatus.SKIPPED == status && (SKIPPED_STATUS_TRACKER.containsKey(instance) || (TestMethodType.BEFORE_METHOD == type + && getAttribute(testResult, RP_RETRY) != null))) { rq.setIssue(Launch.NOT_ISSUE); } - if(ItemStatus.SKIPPED == status && BEFORE_METHODS.contains(type) && testResult.getThrowable() != null) { + if (ItemStatus.SKIPPED == status && BEFORE_METHODS.contains(type) && testResult.getThrowable() != null) { sendReportPortalMsg(testResult); SKIPPED_STATUS_TRACKER.put(instance, Boolean.TRUE); } @@ -533,13 +529,9 @@ protected StartTestItemRQ buildStartTestItemRq(@Nonnull ITestContext testContext StartTestItemRQ rq = new StartTestItemRQ(); Set attributes = rq.getAttributes() == null ? new HashSet<>() : new HashSet<>(rq.getAttributes()); rq.setAttributes(attributes); - ofNullable(testContext.getCurrentXmlTest()).map(XmlTest::getXmlClasses).ifPresent(xmlClasses -> xmlClasses.forEach(xmlClass -> { - String className = xmlClass.getName(); - String codeRef = rq.getCodeRef(); - rq.setCodeRef(codeRef == null ? className : codeRef + ";" + className); - ofNullable(xmlClass.getSupportClass()).map(c -> c.getAnnotation(Attributes.class)) - .ifPresent(a -> attributes.addAll(AttributeParser.retrieveAttributes(a))); - })); + ofNullable(testContext.getCurrentXmlTest()).map(XmlTest::getXmlClasses) + .ifPresent(xmlClasses -> xmlClasses.forEach(xmlClass -> ofNullable(xmlClass.getSupportClass()).map(c -> c.getAnnotation( + Attributes.class)).ifPresent(a -> attributes.addAll(AttributeParser.retrieveAttributes(a))))); rq.setName(testContext.getName()); rq.setStartTime(testContext.getStartDate()); rq.setType("TEST"); @@ -719,7 +711,7 @@ protected String createConfigurationDescription(ITestResult testResult) { */ protected String createStepName(ITestResult testResult) { var methodDisplayNameOptional = getMethodAnnotation(DisplayName.class, testResult); - if(methodDisplayNameOptional.isPresent()){ + if (methodDisplayNameOptional.isPresent()) { return methodDisplayNameOptional.get().value(); } String testStepName = testResult.getTestName(); @@ -734,7 +726,7 @@ protected String createStepName(ITestResult testResult) { */ protected String createStepDescription(ITestResult testResult) { var methodDescriptionOptional = getMethodAnnotation(Description.class, testResult); - if(methodDescriptionOptional.isPresent()){ + if (methodDescriptionOptional.isPresent()) { return methodDescriptionOptional.get().value(); } return testResult.getMethod().getDescription(); @@ -747,8 +739,13 @@ private TestCaseIdEntry getTestCaseId(@Nonnull String codeRef, @Nonnull ITestRes List parameters = ofNullable(testResult.getParameters()).map(Arrays::asList).orElse(null); TestCaseIdEntry id = getMethodAnnotation(TestCaseId.class, testResult - ).flatMap(a -> ofNullable(method).map(m -> TestCaseIdUtils.getTestCaseId(a, m, codeRef, parameters, instance))) - .orElse(TestCaseIdUtils.getTestCaseId(codeRef, parameters)); + ).flatMap(a -> ofNullable(method).map(m -> TestCaseIdUtils.getTestCaseId( + a, + m, + codeRef, + parameters, + instance + ))).orElse(TestCaseIdUtils.getTestCaseId(codeRef, parameters)); return id == null ? null : id.getId().endsWith("[]") ? new TestCaseIdEntry(id.getId().substring(0, id.getId().length() - 2)) : id; } @@ -807,12 +804,14 @@ Maybe getConfigParent(ITestResult testResult, TestMethodType type) { /** * Extension point to customize test step description with error message + * * @param testResult TestNG's testResult context * @return Test/Step Description being sent to ReportPortal */ private String getLogMessage(ITestResult testResult) { String error = String.format(DESCRIPTION_ERROR_FORMAT, ExceptionUtils.getStackTrace(testResult.getThrowable())).trim(); return ofNullable(createStepDescription(testResult)).filter(StringUtils::isNotBlank) - .map(description -> MarkdownUtils.asTwoParts(description, error)).orElse(error); + .map(description -> MarkdownUtils.asTwoParts(description, error)) + .orElse(error); } } From c73307ff1f75b7e15c0b7a1f57bcac7cf78b7b90 Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Fri, 11 Oct 2024 09:46:09 +0300 Subject: [PATCH 6/8] Client version update --- CHANGELOG.md | 2 +- build.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index de2b4cd..4212f07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## [Unreleased] ### Changed -- Client version updated on [5.2.14](https://github.com/reportportal/client-java/releases/tag/5.2.14), by @HardNorth +- Client version updated on [5.2.15](https://github.com/reportportal/client-java/releases/tag/5.2.15), by @HardNorth - Format of last error log of test in item description was updated, by @HardNorth ## [5.4.2] diff --git a/build.gradle b/build.gradle index 1db06c1..91789c3 100644 --- a/build.gradle +++ b/build.gradle @@ -39,7 +39,7 @@ repositories { } dependencies { - api 'com.epam.reportportal:client-java:5.2.14' + api 'com.epam.reportportal:client-java:5.2.15' compileOnly "org.testng:testng:${testng_version}" implementation 'org.slf4j:slf4j-api:2.0.4' From 0eeb08316e0fd660b1eb87236a650cf12c36fd01 Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Fri, 11 Oct 2024 09:46:32 +0300 Subject: [PATCH 7/8] commons-io version update --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 91789c3..b70a545 100644 --- a/build.gradle +++ b/build.gradle @@ -62,7 +62,7 @@ dependencies { testImplementation 'com.epam.reportportal:logger-java-logback:5.2.2' - testImplementation 'org.apache.commons:commons-io:1.3.2' + testImplementation 'commons-io:commons-io:2.17.0' testImplementation 'com.ibm.icu:icu4j:67.1' testImplementation ('com.google.inject:guice:5.1.0') { exclude module: 'guava' From 871735c05bea729b9a00b21582220fe7993d6e5f Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Fri, 11 Oct 2024 09:49:12 +0300 Subject: [PATCH 8/8] CHANGELOG.md update --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4212f07..48a2c9d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ ### Changed - Client version updated on [5.2.15](https://github.com/reportportal/client-java/releases/tag/5.2.15), by @HardNorth - Format of last error log of test in item description was updated, by @HardNorth +### Removed +- Code reference report on Test NG's "Test" level to address issues with reruns, by @HardNorth ## [5.4.2] ### Added