Book Image

Cucumber Cookbook

By : Shankar Garg
Book Image

Cucumber Cookbook

By: Shankar Garg

Overview of this book

Table of Contents (13 chapters)
Cucumber Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Overriding Options from the Terminal


When it is necessary to override the options mentioned in the JUnit Runner, then we need Dcucumber.options from the Terminal. Let's look at some of the practical examples.

How to do it…

  1. If we want to run a Scenario by specifying the filesystem path, run the following command and look at the output:

    mvn test -Dcucumber.options="src/test/java/com/features/sample.feature:5"
    

    In the preceding code, "5" is the Feature file line number where a Scenario starts.

  2. If we want to run the test cases using Tags, then we run the following command and notice the output:

    mvn test -Dcucumber.options="--tags @sanity"
    

    The following is the output of the preceding command:

  3. If we want to generate a different report, then we can use the following command and see the JUnit report generate at the location mentioned:

    mvn test -Dcucumber.options="--plugin junit:target/cucumber-junit-report.xml"
    

How it works…

When you override the options with -Dcucumber.options, you will completely override...