Beginner Chapter 7 · 9 min read

Test Runner & Execution

Configure the Cucumber test runner, set options for features/glue/plugins, run from CLI/IDE, and understand execution flow.

Running Cucumber Tests

The test runner is the entry point that tells Cucumber where to find feature files, step definitions, and how to report results. In Java it's a class with annotations; in Python it's the behave CLI.

TestRunner.java
package com.bdd.course.runner;

import io.cucumber.testng.AbstractTestNGCucumberTests;
import io.cucumber.testng.CucumberOptions;
import org.testng.annotations.DataProvider;

@CucumberOptions(
    features = "src/test/resources/features",   // Feature files path
    glue = "com.bdd.course.stepdefinitions",     // Step definitions package
    plugin = {
        "pretty",                                // Console output
        "html:target/cucumber-reports.html",     // HTML report
        "json:target/cucumber.json",             // JSON report
        "junit:target/cucumber.xml"              // JUnit XML
    },
    tags = "@smoke or @regression",              // Tag filter
    monochrome = true,                           // Clean console output
    dryRun = false                               // true = validate without running
)
public class TestRunner extends AbstractTestNGCucumberTests {

    // Enable parallel scenario execution
    @Override
    @DataProvider(parallel = true)
    public Object[][] scenarios() {
        return super.scenarios();
    }
}

// Run from CLI:
//   mvn test
//   mvn test -Dcucumber.filter.tags="@smoke"
//   mvn test -Dcucumber.features="src/test/resources/features/login.feature"
//
// Run from IDE:
//   Right-click TestRunner.java -> Run
cucumber.properties
# src/test/resources/cucumber.properties
cucumber.publish.quiet=true
cucumber.plugin=pretty, html:target/cucumber-reports.html
cucumber.glue=com.bdd.course.stepdefinitions
cucumber.features=src/test/resources/features
run_commands.sh
# Run all features
behave

# Run a specific feature
behave features/login.feature

# Run scenarios by tag
behave --tags=@smoke
behave --tags="@smoke and @login"
behave --tags="not @wip"

# Dry run (validate steps without executing)
behave --dry-run

# Verbose output
behave -v

# Generate JUnit XML report
behave --junit --junit-directory=reports/

# Stop on first failure
behave --stop

# Run specific scenario by name
behave --name="Successful login"

# Show snippets for undefined steps
behave --snippets
behave.ini
# behave.ini — Behave configuration
[behave]
paths = features
format = pretty
stdout_capture = false
stderr_capture = false
log_capture = false
default_tags = not @wip

# Allure reporting:
# behave -f allure_behave.formatter:AllureFormatter -o reports/allure

Cucumber BDD Beginner Test Runner & Execution

Written by PV

© 2026 All Rights Reserved