Overview
TheCucumberRunner class is the entry point for executing Cucumber tests in the Makers BTG Tests framework. It uses JUnit Platform Suite annotations to configure the Cucumber engine, specify test locations, and set up reporting plugins.
Class Definition
Annotations
@Suite
Marks this class as a JUnit Platform test suite. This annotation is required to enable the JUnit Platform Suite engine to discover and execute this runner.
@IncludeEngines
Specifies which test engines should be included when running the suite.Value:
"cucumber"This ensures that only the Cucumber test engine is used to execute tests, enabling Cucumber’s BDD-style test execution.@SelectClasspathResource
Defines the classpath location where feature files are stored.Value:
"features"The runner will scan the src/test/resources/features/ directory for .feature files to execute.Configuration Parameters
The runner uses multiple@ConfigurationParameter annotations to configure Cucumber’s behavior:
Glue Path Configuration
Specifies the package where step definition classes are located.Key:
Value:
cucumber.glueValue:
"org.btg.practual.stepDefinitions"Cucumber will scan this package to find methods annotated with @Dado, @Cuando, and @Entonces (Spanish Gherkin keywords) that implement test steps.Tag Filtering
Filters which scenarios to execute based on Cucumber tags.Key:
Value:
cucumber.filter.tagsValue:
"@test"Only scenarios annotated with @test in feature files will be executed. This allows selective test execution and helps organize test suites by environment or priority.Plugin Configuration
Configures reporting and output plugins for test execution.Key:
Value:
cucumber.pluginValue:
"io.cucumber.core.plugin.SerenityReporterParallel,pretty,html:target/cucumber-report.html"This configuration enables three plugins:- SerenityReporterParallel: Generates Serenity BDD reports with parallel execution support
- pretty: Provides colored console output with readable test results
- html:target/cucumber-report.html: Generates an HTML report in the target directory
Publish Settings
Suppresses the Cucumber publish banner in console output.Key:
Value:
cucumber.publish.quietValue:
"true"When set to true, Cucumber won’t display messages about publishing reports to Cucumber Reports service.How It Works
Test Discovery Process
Test Discovery Process
When the CucumberRunner is executed:
- JUnit Platform detects the
@Suiteannotation and initializes the suite engine - Cucumber Engine is activated via
@IncludeEngines("cucumber") - Feature Files are discovered in the
featuresclasspath resource - Tag Filtering is applied - only scenarios with
@testtag are selected - Step Definitions are loaded from
org.btg.practual.stepDefinitionspackage - Test Execution begins, matching feature file steps to step definition methods
- Reports are generated using the configured plugins
Parallel Execution Support
Parallel Execution Support
The runner is configured with
SerenityReporterParallel, which enables thread-safe reporting during parallel test execution. This allows multiple scenarios to run concurrently while maintaining accurate test reports.To enable parallel execution, configure JUnit Platform properties in junit-platform.properties:Usage
Running Tests
Execute the test suite using Maven:Running with Custom Tags
To override the@test tag filter and run specific scenarios:
Generating Reports
After test execution, reports are generated in:- HTML Report:
target/cucumber-report.html - Serenity Reports:
target/site/serenity/(generated withmvn serenity:aggregate)
The CucumberRunner class itself is empty because all configuration is handled through annotations. The JUnit Platform reads these annotations at runtime to configure and execute tests.
Related Classes
- Step Definitions - Implementation of test steps
- Test Scenarios - Feature file structure and syntax
Package Location
src/test/java/org/btg/practual/runners/CucumberRunner.java