To integrate Cucumber-style reports into Katalon Studio or customize Katalon reports to mimic Cucumber’s format:
Option 1: Generate Standalone Cucumber HTML Reports
Use Cucumber’s built-in reporting tools alongside Katalon’s execution.
Step 1: Add Cucumber Reporting Dependencies
Modify your project’s build.gradle:
dependencies {
// Cucumber Reporting Plugin (for HTML reports)
implementation 'net.masterthought:cucumber-reporting:5.7.6'
}
Run gradle katalonCopyDependencies
to install the library.
Step 2: Configure Cucumber to Generate JSON Output
In your Cucumber runner class, specify JSON output:
@RunWith(Cucumber.class)
@CucumberOptions(
features = "Include/features",
glue = "com.your.steps",
plugin = [
"json:Reports/cucumber.json" // Output JSON to Reports/
]
)
public class CucumberRunner {}
Step 3: Generate Cucumber HTML Report Post-Execution
Add a Groovy script (e.g., GenerateCucumberReport.groovy
) in Listeners
:
import net.masterthought.cucumber.Configuration
import net.masterthought.cucumber.ReportBuilder
@AfterTestSuite
def generateCucumberReport(TestSuiteContext context) {
def jsonFiles = ["Reports/cucumber.json"]
def reportDir = new File("Reports/cucumber-html")
Configuration config = new Configuration(reportDir, "Your Project Name")
config.setStatusFlags(true, false, false) // Skipped, Pending, Undefined
ReportBuilder reportBuilder = new ReportBuilder(jsonFiles, config)
reportBuilder.generateReports()
println "Cucumber HTML report generated at: ${reportDir}/cucumber-html-reports"
}
Option 2: Customize Katalon Reports to Resemble Cucumber
Modify Katalon’s default report to include Gherkin steps and behavior-driven details.
Step 1: Use Listeners to Log Gherkin Steps
Add a test listener to inject Gherkin steps into Katalon’s logs:
import com.kms.katalon.core.annotation.BeforeTestCase
import com.kms.katalon.core.context.TestCaseContext
class CucumberReportListener {
@BeforeTestCase
def beforeTestCase(TestCaseContext testCaseContext) {
// Log feature/scenario names as Katalon report entries
KeywordLogger log = new KeywordLogger()
log.logInfo("Scenario: " + testCaseContext.getTestCaseId())
}
}
Step 2: Embed Cucumber Screenshots in Katalon Report
Capture screenshots for each step:
import com.kms.katalon.core.annotation.AfterStep
import com.kms.katalon.core.model.FailureHandling
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
class ScreenshotListener {
@AfterStep
def afterStep(TestCaseContext context) {
WebUI.takeScreenshot("screenshots/step_${context.getStepIndex()}.png", FailureHandling.CONTINUE_ON_FAILURE)
}
}
Option 3: Hybrid Approach (Recommended)
- Run Cucumber Tests in Katalon using the built-in Cucumber runner.
- Generate Both Reports:
- Katalon’s default report (for CI/CD integration).
- Cucumber HTML report (for stakeholder-friendly visuals).
Key Notes
- Report Location: Cucumber reports will be in
Reports/cucumber-html-reports/index.html
.
- CI/CD Integration: Add the report generation step to your pipeline:
# Example for Jenkins
java -cp "Libs/*" net.masterthought.cucumber.ReportBuilder Reports/cucumber.json -o Reports/
Troubleshooting
- If no JSON file is generated, check:
- Cucumber
plugin
configuration in the runner.
- File write permissions in the
Reports
folder.
- For dependency conflicts, exclude older Cucumber/Selenium versions in
build.gradle
:
implementation ('io.cucumber:cucumber-java:7.14.0') {
exclude group: 'org.seleniumhq.selenium', module: 'selenium-java'
}
Use Option 1 for standalone Cucumber reports or Option 2 to enhance Katalon’s native reports