spring-bootcucumberspring-boot-testcucumber-javacucumber-junit

cucumber-junit-platform-engine does not pickup feature path from mvn command


I am using Cucumber 7.13.0 with Junit 5 (cucumber-junit-platform-engine - 7.13.0). My tests are only picking feature file path configured in TestRunner class.

they are not picking up feature file from my mvn command
mvn test -Dcucumber.options=src/test/resources/features/dev

Previously with other version of cucumber, i have seen that using @cucumberOptions annotations works seamlessly. only failing after upgrade and with new annotations. Can someone help me with this please ?

Below is my TestRunner class look like
Trial 1: -

@Suite  
@IncludeEngine("cucumber")  
@SelectClassPathResource("features/local")  
@SelectClassPathResource("features/")  
@ConfigurationParameter(key= "cucumber.glue", value="com.mytests")  
public class TestRunner {

}

Trial 2: -

@Suite@IncludeEngine("cucumber")  
@SelectClassPathResource("features/")  
@ConfigurationParameter(key= "cucumber.glue", value="com.mytests")  
@ConfigurationParameter(key= "cucumber.features", value="src/test/resources/features/local")  
public class TestRunner {}

Trial 3: -

@Suite@IncludeEngine("cucumber")  
@SelectClassPathResource("features/")  
@ConfigurationParameter(key= "cucumber.glue", value="com.mytests")  
@ConfigurationParameter(key= "cucumber.options", value="src/test/resources/features/local")  
public class TestRunner {}

All my above attempts are only running feature file inside 'local' directory. I need to run them from the path specified in mvn command,

sample mvn command used

mvn test -Dcucumber.options="src/test/resources/features/dev"


Solution

  • The cucumber.options property was deprecated in v5 and removed in v6. You'll want to use cucumber.features.

    However because you are using the Cucumber Engine and the Suite Engine to run the Cucumber Engine there are two executions of Cucumber.

    The first execution comes from Maven which runs Cucumber directly but doesn't request features to be executed. The second execution comes from Maven which runs the Suite Engine which runs Cucumber and does request features.

    This can be avoided by using -Dsurefire.includeJUnit5Engines=cucumber.

    Then you'll notice that Surefire says no tests have run. This is a lie, Surefire just can't report on tests that don't have a class as the test root.

    Fortunately Cucumber did run. To tell Cucumber to write a report you can use -Dcucumber.plugin=pretty

    So the full command is:

    mvn test -Dsurefire.includeJUnit5Engines=cucumber -Dcucumber.plugin=pretty -Dcucumber.features=src/test/resources/io/cucumber/skeleton/belly.feature