Cucumber Options

Profile picture for user devraj

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 TypeOptional Element and Description
booleandryRun
String[]features
String[]format deprecated. use plugin()
String[]glue
String[]junit
booleanmonochrome
String[]name
String[]plugin
SnippetTypesnippets
booleanstrict
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 {

}