Overriding the Cucumber Options

Sometimes, depending on the requirements, we would like to override default Cucumber behavior, such as reporting or the project structure, and so on. We can configure Cucumber via the Terminal, but mostly we run Cucumber with JUnit. So how do we configure Cucumber with JUnit Runners, let's see this in our next section.

How to do it…

  1. Add @CucumberOptions to the RunCuckeTest.java class and import Cucumber.api.CucumberOptions. This is how the updated code for RunCukeTest.java should look like:
    package com.CucumberOptions; import org.junit.runner.RunWith; import Cucumber.api.CucumberOptions; import Cucumber.api.junit.Cucumber; @RunWith(Cucumber.class) @CucumberOptions( //your Cucumber Options code goes here ) public class ...

Get Cucumber Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.