Udemy REST Assured free

Cucumber Options: Dry Run

Dry run gives you a way to quickly scan your features without actually running them. It make sure that every Step have the corresponding method available in the Step Definition file. dryRun option can either set as true or false.

True: It means that Cucumber will only checks that every Step mentioned in the Feature File have corresponding code written in Step Definition file or not. So in case any of the function is missed in the Step Definition for any Step in Feature File, it will give us the message. Here code inside step definition method will not execute.

False: When it is set to false, all statements/code inside the step definitions method will execute.

Method Signature: public abstract boolean dryRun
Returns: true if this is a dry run
Default: false

Example of Cucumber Dry Run

Runner Class

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,
		strict = true,
		dryRun = true
		)

public class Runner {

}

JUnit Output when dryRun set to true

cucumber dryRun set to true

Take a look at the time duration at the end of the every Steps, it is very less. It means none of the Step is executed but still Cucumber has made sure that every Step have the corresponding method available in the Step Definition file.

JUnit Output when dryRun set to false

Junit Output when Dry Run set to false

Take a look at the time duration now at the end of the every Steps, it comparatively higher compare to previous execution. That is because code inside all step definitions are executed.

Video Tutorial: How to use Dry Run Option inside @CucumberOption annotation