Passing file with feature + line number in cucumber.features with Cucumber 7

3 weeks ago 15
ARTICLE AD BOX

With older versions of Cucumber (before Cucumber 7), I was able to run tests by providing a file (.txt file) that contains the path to the feature file and the line number for scenario.

Eg: cucumberTests.txt has the content

file:src/test/resources/features/test_api.feature:18

And the argument to notify where to find this file was passed in mvn through:

-Dcucumber.options=@C:\path\to\file\cucumberTests.txt

With the onset of Cucumber 7 and Junit 5, the use of cucumber.options has been removed and the use of cucumber.features is provided. I have the following configuration in my TestRunner.java

@Suite @IncludeEngines("cucumber") @SelectClasspathResource("feature") // glue property provided using @ConfigurationParameter // plugin property provided using @ConfigurationParameter

I'm able to run my cucumber tests using

-Dcucumber.features="src/test/resources/features/test_api.feature" -Dcucumber.filter.tags="@test1"

But, my usecase requires me to run with file name and scenario number, and no matter which way I try to provide, it doesnt work with any of the combination.

-Dcucumber.features=@C:\path\to\file\cucumberTests.txt

OR

-Dcucumber.features=@src/test/resources/features/test_api.feature:18

I have already tried a couple of things like changing the contents of cucumberTests.txt to:

src/test/resources/features/test_api.feature:18

and also tried by removing the @SelectClasspathResource("feature") parameter from the TestRunner file. But none of them is working.

Version used: cucumber - 7.20.1

Read Entire Article