Skip to main content

Extent Reports integration

Extent Reports is a customizable HTML reporting library for Java and .NET that provides interactive and detailed test reports. It offers features such as pie charts, logs, screenshots, and more, making it a popular choice for test reporting in automation frameworks.

Integrating with Extent Reports allow you to streamline test reporting and enhance visibility from Katalon Studio built-in test reports. These reports are visually appealing and easy to navigate, making it simpler to understand the test outcomes.

This document shows you how to set up and generate Extent Reports after a test suite execution in Katalon Studio.

Install the plugin
  1. Install the Extent Reports plugin from Katalon Store.
  2. After installing successfully, go to Katalon Studio > Profile > Reload Plugins to double-check that the plugin is available.
    djhfjf
Create Test Listener: To apply Extent Reports, you need to set up test listeners that initialize and generate Extent Report after each test suite execution.
  1. In Tests Explorer, select Test Listeners > New > New Test Listener.
  2. Give the test listener a name, for example, ExtentReportsListeners, then click OK.
  3. Copy and paste the following code into the test listener script:
    Adjust your test report name in this method: attachEReport'(testSuiteContext, "<Report title>", "<Report name>").
    import java.nio.file.Path
    import java.nio.file.Paths;
    import com.kms.katalon.core.annotation.AfterTestCase
    import com.kms.katalon.core.annotation.AfterTestSuite
    import com.kms.katalon.core.annotation.BeforeTestCase
    import com.kms.katalon.core.annotation.BeforeTestSuite
    import com.kms.katalon.core.configuration.RunConfiguration
    import com.kms.katalon.core.context.TestCaseContext
    import com.kms.katalon.core.context.TestSuiteContext

    class ExtentReportsListeners {

    @BeforeTestSuite
    def sampleBeforeTestSuite(TestSuiteContext testSuiteContext) {
    CustomKeywords.'com.katalon.extent.report.ExtentReport.deleteFolderContents'()
    CustomKeywords.'com.katalon.extent.report.ExtentReport.attachEReport'(testSuiteContext, "Extent Report", "KS QA Test Report")
    }

    @BeforeTestCase
    def sampleBeforeTestCase(TestCaseContext testCaseContext) {
    CustomKeywords.'com.katalon.extent.report.ExtentReport.startEReport'(testCaseContext)
    }

    @AfterTestCase
    def sampleAfterTestCase(TestCaseContext testCaseContext) throws IOException {
    CustomKeywords.'com.katalon.extent.report.ExtentReport.takeScreenshotFailure'(testCaseContext)
    }

    @AfterTestSuite
    def sampleAfterTestSuite() {
    CustomKeywords.'com.katalon.extent.report.ExtentReport.flushEReport'()
    }
    }
  4. Open your test case, copy and paste the custom keyword(s) under the corresponding test step you want to capture test execution events.
    Currently Katalon Studio supports two custom keyword for Extent Reports:
    • Attach log to the test step: CustomKeywords.'com.katalon.extent.report.ExtentReport.attachLog'("Add Test Description Here")
    • Take screenshot of the test step: CustomKeywords.'com.katalon.extent.report.ExtentReport.addScreenshot'()
  5. Add the test case to a test suite and execute.
  6. After the execution is finished, click Project > Refresh to load the Extent folder in the Tests Explorer.
  7. Open the .html report to view the generated report of your test execution.