Skip to content

Commit

Permalink
Log finished test information (#1218)
Browse files Browse the repository at this point in the history
  • Loading branch information
MahmoudElSharkawy authored Aug 4, 2023
1 parent 8d04454 commit bd9b843
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/main/java/com/shaft/listeners/TestNGListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ public void afterInvocation(IInvokedMethod iInvokedMethod, ITestResult iTestResu
IssueReporter.updateTestStatusInCaseOfVerificationFailure(iTestResult);
IssueReporter.updateIssuesLog(iTestResult);
TestNGListenerHelper.updateConfigurationMethodLogs(iTestResult);
TestNGListenerHelper.logFinishedTestInformation(iTestResult);
ReportManagerHelper.setDiscreteLogging(SHAFT.Properties.reporting.alwaysLogDiscreetly());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,4 +298,30 @@ public static void logTestInformation(ITestResult iTestResult) {
}
}
}

public static void logFinishedTestInformation(ITestResult iTestResult) {
ITestNGMethod iTestNGMethod = iTestResult.getMethod();
String className;
String methodName;
String methodDescription = "";
String methodStatus = "";

if (!iTestNGMethod.getQualifiedName().contains("AbstractTestNGCucumberTests")) {
if (iTestNGMethod.isTest()) {
className = ReportManagerHelper.getTestClassName();
methodName = ReportManagerHelper.getTestMethodName();
if (iTestNGMethod.getDescription() != null) {
methodDescription = iTestNGMethod.getDescription();
}
if (iTestResult.getStatus() == ITestResult.SUCCESS) {
methodStatus = "Passed";
} else if (iTestResult.getStatus() == ITestResult.FAILURE) {
methodStatus = "Failed";
} else if (iTestResult.getStatus() == ITestResult.SKIP) {
methodStatus = "Skipped";
}
ReportManagerHelper.logFinishedTestInformation(className, methodName, methodDescription, methodStatus);
}
}
}
}
11 changes: 11 additions & 0 deletions src/main/java/com/shaft/tools/io/internal/ReportManagerHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,17 @@ public static void logExecutionSummary(String total, String passed, String faile
createImportantReportEntry(copyrights);
}

public static void logFinishedTestInformation(String className, String testMethodName, String testDescription, String testStatus) {
StringBuilder reportMessage = new StringBuilder();
reportMessage.append("\nFinished Execution of Test Method: '").append(className).append(".").append(testMethodName).append("'");
if (!testDescription.equals("")) {
reportMessage.append("\nTest Description: '").append(testDescription).append("'");
}
reportMessage.append("\nTest Status: '").append(testStatus).append("'");

createImportantReportEntry(reportMessage.toString());
}

public static String formatStackTraceToLogEntry(Throwable t) {
return formatStackTraceToLogEntry(t, false);
}
Expand Down

0 comments on commit bd9b843

Please sign in to comment.