Skip to main content

Overriding Cucumber Options from 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.


		plugin = {"pretty","html:target/cucumber"},
		features = {"features"},
		monochrome = true,
		strict = true,
		dryRun = false,
		tags = {"@smoke"}

This is a code of my Test Runner class, its executing @smoke test cases, to execute @regression test cases I need to replace this @smoke with @regression in my runner class. Every time I want to execute test cases with different tag, I need to modify my Test Runner class which is really bad practice when you are executing using Jenkins and pulling the code from git because every time you need to modify your code and then commit it to git. Even if you are doing it using command line, this would be a waste of time to modify test runner again and again.

Suppose, you want to execute @regression test case instead of @smoke then you need to write below command:

$ mvn test -Dcucumber.options="--tags @regression"

This will override my default Test Runner configuration and execute @regression test cases instead of @smoke.

Submitted by tgoswami on August 30, 2020

Tarun has 11+ years of experience in Quality Assurance in different domains like Banking, E-commerce, Health and Education.


At ProgramsBuzz, you can learn, share and grow with millions of techie around the world from different domain like Data Science, Software Development, QA and Digital Marketing. You can ask doubt and get the answer for your queries from our experts.