diff --git a/src/main/java/com/shaft/listeners/JunitListener.java b/src/main/java/com/shaft/listeners/JunitListener.java index 11651f12e8b..5a5975f1d7b 100644 --- a/src/main/java/com/shaft/listeners/JunitListener.java +++ b/src/main/java/com/shaft/listeners/JunitListener.java @@ -133,8 +133,8 @@ private void appendToExecutionSummaryReport(TestIdentifier testIdentifier, Strin String caseName = testIdentifier.getDisplayName(); String caseDescription = testIdentifier.getLegacyReportingName(); String statusMessage = statusIcon.getValue() + status.name(); - Boolean hasIssue = false; - ExecutionSummaryReport.casesDetailsIncrement(caseSuite, caseName, caseDescription, errorMessage, statusMessage, hasIssue); + // Will add empty strings o the tmsLink and issue params until we figure out how to get the values of the annotations using JUnit + ExecutionSummaryReport.casesDetailsIncrement("", caseSuite, caseName, caseDescription, errorMessage, statusMessage, ""); } } diff --git a/src/main/java/com/shaft/listeners/TestNGListener.java b/src/main/java/com/shaft/listeners/TestNGListener.java index 947b0f3961e..64bffbe8f4c 100644 --- a/src/main/java/com/shaft/listeners/TestNGListener.java +++ b/src/main/java/com/shaft/listeners/TestNGListener.java @@ -214,9 +214,9 @@ public void onExecutionFinish() { public void onTestSuccess(ITestResult result) { // if (isTestNGRun()) { passedTests.add(result.getMethod()); - ExecutionSummaryReport.casesDetailsIncrement(result.getMethod().getQualifiedName().replace("." + result.getMethod().getMethodName(), ""), + ExecutionSummaryReport.casesDetailsIncrement(TestNGListenerHelper.getTmsLinkAnnotationValue(result), result.getMethod().getQualifiedName().replace("." + result.getMethod().getMethodName(), ""), result.getMethod().getMethodName(), result.getMethod().getDescription(), "", - ExecutionSummaryReport.StatusIcon.PASSED.getValue() + ExecutionSummaryReport.Status.PASSED.name(), TestNGListenerHelper.testHasIssueAnnotation(result)); + ExecutionSummaryReport.StatusIcon.PASSED.getValue() + ExecutionSummaryReport.Status.PASSED.name(), TestNGListenerHelper.getIssueAnnotationValue(result)); // } } @@ -224,9 +224,9 @@ public void onTestSuccess(ITestResult result) { public void onTestFailure(ITestResult result) { // if (isTestNGRun()) { failedTests.add(result.getMethod()); - ExecutionSummaryReport.casesDetailsIncrement(result.getMethod().getQualifiedName().replace("." + result.getMethod().getMethodName(), ""), + ExecutionSummaryReport.casesDetailsIncrement(TestNGListenerHelper.getTmsLinkAnnotationValue(result), result.getMethod().getQualifiedName().replace("." + result.getMethod().getMethodName(), ""), result.getMethod().getMethodName(), result.getMethod().getDescription(), result.getThrowable().getMessage(), - ExecutionSummaryReport.StatusIcon.FAILED.getValue() + ExecutionSummaryReport.Status.FAILED.name(), TestNGListenerHelper.testHasIssueAnnotation(result)); + ExecutionSummaryReport.StatusIcon.FAILED.getValue() + ExecutionSummaryReport.Status.FAILED.name(), TestNGListenerHelper.getIssueAnnotationValue(result)); // } } @@ -234,9 +234,9 @@ public void onTestFailure(ITestResult result) { public void onTestSkipped(ITestResult result) { // if (isTestNGRun()) { skippedTests.add(result.getMethod()); - ExecutionSummaryReport.casesDetailsIncrement(result.getMethod().getQualifiedName().replace("." + result.getMethod().getMethodName(), ""), + ExecutionSummaryReport.casesDetailsIncrement(TestNGListenerHelper.getTmsLinkAnnotationValue(result), result.getMethod().getQualifiedName().replace("." + result.getMethod().getMethodName(), ""), result.getMethod().getMethodName(), result.getMethod().getDescription(), result.getThrowable().getMessage(), - ExecutionSummaryReport.StatusIcon.SKIPPED.getValue() + ExecutionSummaryReport.Status.SKIPPED.name(), TestNGListenerHelper.testHasIssueAnnotation(result)); + ExecutionSummaryReport.StatusIcon.SKIPPED.getValue() + ExecutionSummaryReport.Status.SKIPPED.name(), TestNGListenerHelper.getIssueAnnotationValue(result)); // } } } \ No newline at end of file diff --git a/src/main/java/com/shaft/listeners/internal/TestNGListenerHelper.java b/src/main/java/com/shaft/listeners/internal/TestNGListenerHelper.java index 30c91998cea..8d4d63fe845 100644 --- a/src/main/java/com/shaft/listeners/internal/TestNGListenerHelper.java +++ b/src/main/java/com/shaft/listeners/internal/TestNGListenerHelper.java @@ -8,6 +8,8 @@ import com.shaft.tools.io.internal.ReportManagerHelper; import io.qameta.allure.Issue; import io.qameta.allure.Issues; +import io.qameta.allure.TmsLink; +import io.qameta.allure.TmsLinks; import org.openqa.selenium.Platform; import org.openqa.selenium.remote.Browser; import org.testng.*; @@ -259,10 +261,38 @@ public static void skipTestsWithLinkedIssues(ITestResult iTestResult) { } } - public static Boolean testHasIssueAnnotation(ITestResult iTestResult) { + public static String getIssueAnnotationValue(ITestResult iTestResult) { var method = iTestResult.getMethod().getConstructorOrMethod().getMethod(); Issue issue = method.getAnnotation(Issue.class); - return issue != null; + Issues issues = method.getAnnotation(Issues.class); + if (issues != null) { + return Arrays.toString(issues.value()) + .replace("[@io.qameta.allure.Issue(\"", "") + .replace("@io.qameta.allure.Issue(\"", "") + .replace("\")]", "") + .replace("\"),", ","); + } else if (issue != null) { + return issue.value(); + } else { + return ""; + } + } + + public static String getTmsLinkAnnotationValue(ITestResult iTestResult) { + var method = iTestResult.getMethod().getConstructorOrMethod().getMethod(); + TmsLink tmsLink = method.getAnnotation(TmsLink.class); + TmsLinks tmsLinks = method.getAnnotation(TmsLinks.class); + if (tmsLinks != null) { + return Arrays.toString(tmsLinks.value()) + .replace("[@io.qameta.allure.TmsLink(\"", "") + .replace("@io.qameta.allure.TmsLink(\"", "") + .replace("\")]", "") + .replace("\"),", ","); + } else if (tmsLink != null) { + return tmsLink.value(); + } else { + return ""; + } } public static void failFast(ITestResult iTestResult) { diff --git a/src/main/java/com/shaft/tools/internal/support/HTMLHelper.java b/src/main/java/com/shaft/tools/internal/support/HTMLHelper.java index 963e62de9cb..e47d3e4b18d 100644 --- a/src/main/java/com/shaft/tools/internal/support/HTMLHelper.java +++ b/src/main/java/com/shaft/tools/internal/support/HTMLHelper.java @@ -291,9 +291,10 @@ public enum HTMLHelper { .piechart1 { display: block; position: relative; - width: 120px; - height: 120px; + width: 100px; + height: 100px; border-radius: 50%; + margin-top: 20px; background-image: conic-gradient( MediumSeaGreen ${VALIDATION_PASSED_PERCENTAGE_PIE}deg, Tomato 0); @@ -461,15 +462,18 @@ public enum HTMLHelper { .table100.ver5 .ps__rail-y .ps__thumb-y::before{ background-color:#ccc } + .column0{ + width:5%; + padding-left:20px + } .column1{ width:5%; - padding-left:40px } .column2{ width:20% } .column3{ - width:35% + width:30% } .column4{ width:25% @@ -478,7 +482,7 @@ public enum HTMLHelper { width:10% } .column6{ - width:5% + width:10% } hr.rounded { border-top: 8px solid #bbb; @@ -529,10 +533,8 @@ public enum HTMLHelper { Passed: ${VALIDATION_PASSED} | Failed: ${VALIDATION_FAILED} ] -
-
-

${VALIDATION_PASSED_PERCENTAGE}% Passed

+
${VALIDATION_PASSED_PERCENTAGE}% Passed

Total Issues: ${TOTAL_ISSUES}  [ Tests that should Pass: ${NO_OPEN_ISSUES_FAILED} | @@ -561,12 +563,13 @@ public enum HTMLHelper { + - + ${CASES_DETAILS} @@ -602,7 +605,7 @@ public enum HTMLHelper { """), - EXECUTION_SUMMARY_DETAILS_FORMAT(""); + EXECUTION_SUMMARY_DETAILS_FORMAT(""); private final String value; diff --git a/src/main/java/com/shaft/tools/io/internal/ExecutionSummaryReport.java b/src/main/java/com/shaft/tools/io/internal/ExecutionSummaryReport.java index 60f228e66c7..80c612f737e 100644 --- a/src/main/java/com/shaft/tools/io/internal/ExecutionSummaryReport.java +++ b/src/main/java/com/shaft/tools/io/internal/ExecutionSummaryReport.java @@ -16,8 +16,9 @@ public class ExecutionSummaryReport { private static int failedValidations = 0; private static final String SHAFT_LOGO_URL = "https://github.com/ShaftHQ/SHAFT_ENGINE/raw/main/src/main/resources/images/shaft.png"; - public static void casesDetailsIncrement(String caseSuite, String caseName, String caseDescription,String errorMessage, String status, Boolean hasIssue) { + public static void casesDetailsIncrement(String tmsLink, String caseSuite, String caseName, String caseDescription,String errorMessage, String status, String issue) { ArrayList entry = new ArrayList<>(); + entry.add(tmsLink); entry.add(caseSuite); if (caseDescription != null && !caseDescription.isEmpty()) { entry.add(caseDescription); @@ -26,11 +27,7 @@ public static void casesDetailsIncrement(String caseSuite, String caseName, Stri } entry.add(errorMessage); entry.add(status); - if (hasIssue) { - entry.add("Yes"); - } else { - entry.add("No"); - } + entry.add(issue); casesDetails.put(casesDetails.size() + 1, entry); } @@ -49,7 +46,7 @@ public static void generateExecutionSummaryReport(int passed, int failed, int sk int total = passed + failed + skipped; StringBuilder detailsBuilder = new StringBuilder(); - casesDetails.forEach((key, value) -> detailsBuilder.append(String.format(HTMLHelper.EXECUTION_SUMMARY_DETAILS_FORMAT.getValue(), key, value.get(0), value.get(1), value.get(2), value.get(3), value.get(4)))); + casesDetails.forEach((key, value) -> detailsBuilder.append(String.format(HTMLHelper.EXECUTION_SUMMARY_DETAILS_FORMAT.getValue(), key, value.get(0), value.get(1), value.get(2), value.get(3), value.get(4), value.get(5)))); SHAFT.CLI.file().writeToFile(SHAFT.Properties.paths.executionSummaryReport(), "ExecutionSummaryReport_" + new SimpleDateFormat("dd-MM-yyyy_HH-mm-ss-SSSS-aaa").format(System.currentTimeMillis()) + ".html",
Id Suite Name Error StatusHas issueissue id
%d%s%s%s%s%s
%d%s%s%s%s%s%s