dimanche 21 juillet 2019

Using multiple classes in Cucumber glue option package

I have a problem using the glue option when running Cucumber tests. Here's my test runner class:

@RunWith(Cucumber.class)
@CucumberOptions(features="src/test/java/com/xcase/tests/cucumber/features/api/APITest.feature",glue={"com.xcase.tests.cucumber.stepdefinitions.api"})
public class APIRunnerTest {

}

I run the tests along these lines:

mvn clean test -Dtest=APIRunnerTest

If I put all of my step definitions in a single class in the glue package, com.xcase.tests.cucumber.stepdefinitions.api.FirstSteps, then my tests run fine.

If I add an empty class to the com.xcase.tests.cucumber.stepdefinitions.api package, say com.xcase.tests.cucumber.stepdefinitions.api.SecondSteps, then my tests run fine. However, if I modify SecondSteps to extend FirstSteps, then my tests stop running completely! Why is that?

This is a problem for me because I'd like to put some shared step definitions and fields in a base step definition class and then have multiple classes that extend the base class. How should I do this?

Aucun commentaire:

Enregistrer un commentaire