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…
- Add
@CucumberOptions
to theRunCuckeTest.java
class and importCucumber.api.CucumberOptions
. This is how the updated code forRunCukeTest.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 RunCukeTest { }
- Now, let's specify configurations where our Feature files and Step Definitions are located and which Tags are used. This is how the code for
RunCukeTest.java
should look like:package com.CucumberOptions; import...