I developed and published a GitHub project:
This project proposes a solution to the problem raised at the topic in the Katalon Community :
The original poster argued:
zedromason
Nov 12
Hello, is there a setting to generate an HTML file so it can be accessed immediately before the test script is finished?
I’m having trouble. I manually integrated Jira with a listener and uploaded supporting documents to Jira. The only files my script can upload are .png and console0, but the HTML file isn’t found because it only appears after the script finishes running.
Problem to solve
Katalon Studio generates a built-in HTML report after the Test Suite is entirely finished; after the @AfterTestSuite-annotated method in Test Listener finished. But I want to generate the built-in HTML report in the @AfterTestSuite-annotated method and post-process the file further (e.g., upload to JIRA).
Solution
A @AfterTestSuite-annotated method in my Test Listener should invoke the processing of generating the built-in HTML report. I would not rely on Katalon Studio to generate it. I will trigger it myself.
Solution Description
I developed a Test Listener Test Listeners/PurgeHTMLReport.groovy, which is as short as this:
import java.nio.file.Path
import java.nio.file.Paths
import com.kms.katalon.core.annotation.AfterTestSuite
import com.kms.katalon.core.configuration.RunConfiguration
import com.kms.katalon.core.context.TestSuiteContext
import com.kms.katalon.core.logging.model.TestSuiteLogRecord
import com.kms.katalon.core.reporting.ReportWriterUtil
import com.kms.katalon.core.reporting.ReportWriterUtil.SuiteReportGenerationOptionsBuilder
import com.kms.katalon.core.setting.ReportBundleSettingStore
class PurgeHTMLReport {
@AfterTestSuite
def afterTestSuite(TestSuiteContext testSuiteContext) {
String projectDir = RunConfiguration.getProjectDir()
Path reportFolder = Paths.get(RunConfiguration.getReportFolder())
Path exportLocation = reportFolder.resolve("test-suite-report.html")
File report = exportTestSuite(exportLocation.toFile(), projectDir, reportFolder.toFile())
println "HTML report: " + report.toString()
}
/**
* quoted from com.kms.katalon.core.reporting.KatalonExportReportProvider#exportTestSuite() with slight modifications
*/
File exportTestSuite(File exportLocation, String projectDir, File reportFolder) {
def settings = ReportBundleSettingStore.getStore(projectDir).getSettings()
assert reportFolder.exists()
TestSuiteLogRecord testSuiteLogRecord =
ReportWriterUtil.parseTestSuiteLog(reportFolder.getAbsolutePath())
ReportWriterUtil.writeHTMLReport(
SuiteReportGenerationOptionsBuilder.create()
.suiteLogRecord(testSuiteLogRecord)
.settings(settings)
.reportDir(reportFolder)
.outputFile(exportLocation)
.build())
return exportLocation
}
}
With this Test Listener implemented, I ran a Test Suite. In the Reports folder, I could find a new file named test-suite-report.html was generated by my Test Listener PurgeHTMLReport:
The test-suite-report.html looked just fine. I found nothing wrong in the new HTML report.
I can do any post-processing over the new test-suite-report.html in my @AfterTestSuite-annotated method in the TestListener PurgeTestSuiteReport. I can upload the file to any external locations such as JIRA, GitHub Issues, Slack etc.
How I invented this solution.
Every Katalon studio installation contains the source codes of com.kms.katalon.core.* classes. You can find it in the $KATALON_STUIO_INSTALLATION_FOLDER/configuration/resources/source. I read the source code. of com.kms.katalon.core.reporting.KatalonExportReportProvider class. Especially the exportTestSuite method was most interesting, which looks as follows:
@Override
public File exportTestSuite(File exportLocation, String projectDir, String reportId, String formatType)
throws IOException, URISyntaxException, XMLParserException, XMLStreamException {
var settings = ReportBundleSettingStore.getStore(projectDir).getSettings();
File reportFolder = new File(projectDir, reportId);
TestSuiteLogRecord testSuiteLogRecord = ReportWriterUtil.parseTestSuiteLog(reportFolder.getAbsolutePath());
switch (formatType) {
case "HTML":
ReportWriterUtil.writeHTMLReport(SuiteReportGenerationOptionsBuilder.create()
.suiteLogRecord(testSuiteLogRecord)
.settings(settings)
.reportDir(reportFolder)
.outputFile(exportLocation)
.build());
return exportLocation;
case "CSV (Summary)":
ReportWriterUtil.writeLogRecordToCSVFile(testSuiteLogRecord, exportLocation,
Arrays.asList(testSuiteLogRecord.filterFinalTestCasesResult()), false);
return exportLocation;
case "CSV (Details)":
ReportWriterUtil.writeLogRecordToCSVFile(testSuiteLogRecord, exportLocation,
Arrays.asList(testSuiteLogRecord.filterFinalTestCasesResult()), true);
return exportLocation;
case "PDF":
TestSuitePdfGenerator pdfGenerator = new TestSuitePdfGenerator(testSuiteLogRecord);
try {
pdfGenerator.exportToPDF(exportLocation.getAbsolutePath());
} catch (JasperReportException e) {
logger.logWarning(ExceptionsUtil.getStackTraceForThrowable(e));
throw new IOException(e);
}
return exportLocation;
default:
break;
}
return null;
}
I thought that Katalon Studio calls this method to generate the HTML report. The method signature was easy to understand. I would be able to write a @AfterTestSuite-annotated method in my Test Listener that implement the report generation in the similar way.
Required Katalon Version
The PugeHTMLReport class requires Katalon Studio v10.x. It will not work on v9.x and older.
Conclusion
So I tried implementing it. Done it. It looks working fine.


