Skip to main content

Cucumber Options

In our JUnit Test Runner class, we us @CucumberOptions annotation. @CucumberOptions are like property file or settings for our test. It provide several option which we use while working with cucumber command line options.

While using IDE like Eclipse, this is very useful and help us to execute our project in several ways. We declare it inside our JUnit Test runner class.

There are several options which you can use as a part of this annotation. Below is the list:

Modifier and Type Optional Element and Description
boolean dryRun
String[] features
String[] format deprecated. use plugin()
String[] glue
String[] junit
boolean monochrome
String[] name
String[] plugin
SnippetType snippets
boolean strict
String[] tag

Check below example, using several cucumber options:

import org.junit.runner.RunWith;

import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;

@RunWith(Cucumber.class)
@CucumberOptions(
		plugin = {"pretty", "html:target/cucumber"},
		features = {"features"},
		glue={"com.pb.cucumbertest.stepdefinitions"},
		monochrome = true,
		tags = {"@contactus"},
		dryRun = false,
		strict = true
		)

public class Runner {

}

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.

About

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.