Skip to content
Branch: master
Find file History
Type Name Latest commit message Commit time
Failed to load latest commit information.
src [TestNG] Remove gherkin from Cucumber TestNG API Aug 17, 2019
.gitignore [Core] Add property to select io.cucumber.core.backend.ObjectFactory … Jul 16, 2019 [TestNG] Improve Jul 21, 2019
pom.xml [All] Set version to 5.0.0-SNAPSHOT Jul 31, 2019

Cucumber TestNG

Use TestNG to execute cucumber scenarios. To use add the cucumber-testng dependency to your pom.


Create an empty class that extends the AbstractTestNGCucumberTests.

package io.cucumber.runtime.testng;

import io.cucumber.testng.AbstractTestNGCucumberTests;
import io.cucumber.testng.CucumberOptions;

@CucumberOptions(plugin = "json:target/cucumber-report.json")
public class RunCucumberTest extends AbstractTestNGCucumberTests {

This will execute all scenarios in same package as the runner, by default glue code is also assumed to be in the same package. The @CucumberOptions can be used to provide additional configuration to the runner.

Test composition

It is possible to use TestNG without inheriting from AbstractTestNGCucumberTests by using the TestNGCucumberRunner. See the RunCukesByCompositionTest Example for usage.


Cucumber provides limited support for SkipException.

  • Throwing a SkipException results in both Cucumber and TestNG marking the test as skipped.
  • Throwing a subclass of SkipException results in Cucumber marking the test as failed and TestNG marking the test as skipped.

Parallel execution

Cucumber TestNG supports parallel execution of scenarios. Override the scenarios method to enable parallel execution.

public class RunCucumberTest extends AbstractTestNGCucumberTests {

    @DataProvider(parallel = true)
    public Object[][] scenarios() {
        return super.scenarios();

Maven Surefire plugin configuation for parallel execution


Where dataproviderthreadcount is the default number of threads to use for data providers when running tests in parallel.

You can’t perform that action at this time.