If you followed the example given in the cucumber-jvm source (https://github.com/cucumber/cucumber-jvm/blob/master/examples/java-calculator-testng/src/test/java/cucumber/examples/java/calculator/RunCukesByFeatureAndCompositionTest.java), then this will create one test per feature due to the DataProvider:
@DataProvider
public Object[][] features() {
return testNGCucumberRunner.provideFeatures();
}
If you modify the DataProvider to return scenarios instead, you'll get one testNG test per scenario instead.
public List<CucumberFeature> getFeatures() {
return runtimeOptions.cucumberFeatures(resourceLoader);
}
public Object[][] provideScenarios() {
try {
List<CucumberFeature> features = getFeatures();
List<Object[]> scenarioList = new ArrayList<Object[]>(features.size());
for (CucumberFeature feature : features) {
List<CucumberTagStatement> scenarios = feature.getFeatureElements();
for (CucumberTagStatement scenario : scenarios) {
// If this is a Scenario Outline, split it up so each one is a test.
if (scenario instanceof CucumberScenarioOutline) {
List<CucumberExamples> cucumberExamplesList = ((CucumberScenarioOutline) scenario).getCucumberExamplesList();
for (CucumberExamples cucumberExamples : cucumberExamplesList) {
List<CucumberScenario> exampleScenarios = cucumberExamples.createExampleScenarios();
for (CucumberScenario exampleScenario : exampleScenarios) {
scenarioList.add(new Object[]{exampleScenario, exampleScenario.getGherkinModel().getName()});
}
}
} else
scenarioList.add(new Object[]{scenario, scenario.getGherkinModel().getName()});
}
}
return scenarioList.toArray(new Object[][]{});
} catch (CucumberException e) {
return new Object[][]{new Object[]{new CucumberExceptionWrapper(e)}};
}
}