How to run single cucumber feature files through command prompt and through jenkins using Maven?
You can run a single feature file by using cucumber.options
which will override all the options you have in the @CucumberOptions
annotation:
mvn test -Dcucumber.options="src/test/features/com/perspecsys/salesforce/featurefiles/Account.feature"
EDIT (Jun 2021):Subsequent versions removed the cucumber.options
construct and replaced it. One way to achieve the same result now is through the use of tags. Place a tag on top of your feature file (example @feature_file_name
) and then run the following command:
mvn test -Dcucumber.filter.tags='@feature_file_name'
You can run a single feature file by using cucumber.options
mvn test -Dcucumber.options="--tags @TestTag"
If you wanted it hard coded, you could do something like:
import cucumber.api.CucumberOptions;import cucumber.api.junit.Cucumber;import org.junit.runner.RunWith;@RunWith(Cucumber.class)@CucumberOptions( features={"src/test/resources/features/belly.feature"} ,glue = "steps" //whatever the name of your steps package is )public class RunCukesTest {}