3
votes

I upgraded the cucumber version I was using to run each cucumber scenario in a different @Test but now my runner can't find my step definition My tests were running fine when I was using cucumber 1.2.5 with the groupId Info.cukes but know that I migrated to 3.0.1 all my tests are skipped and my scenario are undefined. My runner:

@CucumberOptions(
    plugin = {"pretty", "html:target/cucumber"},
    features = "src/main/java/cucumbertests/features"
    , glue = {"cucumbertests.stepdef.customer.CreateCustomerSteps",
    "cucumbertests.stepdef.customer.CustomerTestSteps"
}
)
public class CucumberTestRunner {
    private TestNGCucumberRunner testNGCucumberRunner;

    @BeforeClass(alwaysRun = true)
    public void setUpClass() throws Exception {
        testNGCucumberRunner = new TestNGCucumberRunner(this.getClass());
}

    @Test(description = "Runs Cucumber Scenarios", dataProvider = "scenarios")
    public void scenario(PickleEventWrapper pickleEvent, CucumberFeatureWrapper cucumberFeature) throws Throwable {
        testNGCucumberRunner.runScenario(pickleEvent.getPickleEvent());
    }

    @DataProvider
    public Object[][] scenarios() {
        return testNGCucumberRunner.provideScenarios();
    }

    @AfterClass(alwaysRun = true)
    public void tearDownClass() throws Exception {
        testNGCucumberRunner.finish();
    }
}

I am using the version of cucumber 3.0.1

<cucumber.version>3.0.1</cucumber.version>

    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-jvm</artifactId>
        <version>${cucumber.version}</version>
    </dependency>
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-core</artifactId>
        <version>${cucumber.version}</version>
    </dependency>
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-testng</artifactId>
        <version>${cucumber.version}</version>
    </dependency>
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-spring</artifactId>
        <version>${cucumber.version}</version>
    </dependency>
1

1 Answers

0
votes

If you look at the release notes of testng in cucumber-jvm repo - https://github.com/cucumber/cucumber-jvm/tree/master/testng. There is a link for an example to running with TestNGCucumberRunner - https://github.com/cucumber/cucumber-jvm/blob/master/examples/java-calculator-testng/src/test/java/cucumber/examples/java/calculator/RunCukesByCompositionTest.java

It has additional parameter of groups in the test(scenario()) method - groups = "cucumber". Maybe this fixes the problem