diff --git a/CHANGELOG.md b/CHANGELOG.md index 9832bdb..60e0bde 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## [Unreleased] ### Added - Common Stack Trace frames skip in description and logs, by @HardNorth +- `@Issue` and `@Issues` annotations support, by @HardNorth ### Changed - Client version upgraded on [5.2.20](https://github.com/reportportal/client-java/releases/tag/5.2.20), by @HardNorth diff --git a/src/main/java/com/epam/reportportal/testng/TestNGService.java b/src/main/java/com/epam/reportportal/testng/TestNGService.java index 3ae6cfe..8027ce9 100644 --- a/src/main/java/com/epam/reportportal/testng/TestNGService.java +++ b/src/main/java/com/epam/reportportal/testng/TestNGService.java @@ -15,10 +15,7 @@ */ package com.epam.reportportal.testng; -import com.epam.reportportal.annotations.Description; -import com.epam.reportportal.annotations.DisplayName; -import com.epam.reportportal.annotations.ParameterKey; -import com.epam.reportportal.annotations.TestCaseId; +import com.epam.reportportal.annotations.*; import com.epam.reportportal.annotations.attribute.Attributes; import com.epam.reportportal.listeners.ItemStatus; import com.epam.reportportal.listeners.ListenerParameters; @@ -27,10 +24,7 @@ import com.epam.reportportal.service.item.TestCaseIdEntry; import com.epam.reportportal.service.tree.TestItemTree; import com.epam.reportportal.testng.util.internal.LimitedSizeConcurrentHashMap; -import com.epam.reportportal.utils.AttributeParser; -import com.epam.reportportal.utils.MemoizingSupplier; -import com.epam.reportportal.utils.ParameterUtils; -import com.epam.reportportal.utils.TestCaseIdUtils; +import com.epam.reportportal.utils.*; import com.epam.reportportal.utils.formatting.MarkdownUtils; import com.epam.reportportal.utils.properties.SystemAttributesExtractor; import com.epam.ta.reportportal.ws.model.*; @@ -386,8 +380,7 @@ public void startTestMethod(@Nonnull ITestResult testResult) { */ @Nullable private String getLogMessage(@Nonnull ITestResult testResult) { - String error = ofNullable(testResult.getThrowable()).map(t -> String.format( - DESCRIPTION_ERROR_FORMAT, + String error = ofNullable(testResult.getThrowable()).map(t -> String.format(DESCRIPTION_ERROR_FORMAT, getStackTrace(t, new Throwable()) )).orElse(null); if (error == null) { @@ -479,6 +472,15 @@ private void processFinishRetryFlag(ITestResult testResult, FinishTestItemRQ rq) protected void createSkippedSteps(ITestResult testResult) { } + @Nullable + protected com.epam.ta.reportportal.ws.model.issue.Issue createIssue(@Nonnull ITestResult testResult) { + String stepName = createStepName(testResult); + List parameters = createStepParameters(testResult); + return getMethodAnnotation(Issues.class, testResult).map(i -> IssueUtils.createIssue(i, stepName, parameters)) + .orElseGet(() -> getMethodAnnotation(Issue.class, testResult).map(i -> IssueUtils.createIssue(i, stepName, parameters)) + .orElse(null)); + } + @Override public void finishTestMethod(ItemStatus status, ITestResult testResult) { Maybe itemId = getAttribute(testResult, RP_ID); @@ -514,6 +516,10 @@ && getAttribute(testResult, RP_RETRY) != null))) { processFinishRetryFlag(testResult, rq); + if (type == TestMethodType.STEP) { + rq.setIssue(createIssue(testResult)); + } + Maybe finishItemResponse = launch.get().finishTestItem(itemId, rq); if (launch.get().getParameters().isCallbackReportingEnabled()) { updateTestItemTree(finishItemResponse, testResult); @@ -758,13 +764,8 @@ 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; }