✅ What is dryRun
in Cucumber?
-
It’s a flag used in the
@CucumberOptions
annotation (for TestNG or JUnit runners). -
When set to
true
, it checks the mapping between feature file steps and Java step definition methods. -
It helps to quickly validate if you’ve implemented all step definitions, without launching the browser or app.
dryRun=true
, if a step is not implemented:Feature: Debit Card Payment
@Dryrun
Scenario: Ebay homepage display
Given User is on Ebay homepage
When click on Ebay Icon
Then User navigated to Ebay Homepage
package testRunner;
import io.cucumber.testng.AbstractTestNGCucumberTests;
import io.cucumber.testng.CucumberOptions;
@CucumberOptions(features = "src/test/java/features",glue="Steps", monochrome=true, dryRun = true, tags = "@Dryrun")
public class DryrunTestRunner extends AbstractTestNGCucumberTests{
}
package Steps;
public class DryRun_Steps {
}
Output:
io.cucumber.testng.UndefinedStepException: The step 'User is on Ebay homepage' and 2 other step(s) are undefined.
You can implement these steps using the snippet(s) below:
@Given("User is on Ebay homepage")
public void user_is_on_ebay_homepage() {
// Write code here that turns the phrase above into concrete actions
throw new io.cucumber.java.PendingException();
}
@When("click on Ebay Icon")
public void click_on_ebay_icon() {
// Write code here that turns the phrase above into concrete actions
throw new io.cucumber.java.PendingException();
}
@Then("User navigated to Ebay Homepage")
public void user_navigated_to_ebay_homepage() {
// Write code here that turns the phrase above into concrete actions
throw new io.cucumber.java.PendingException();
}
dryRun=false |
Cucumber executes all tests normally, including setup and test logic. |
dryRun
- While developing new scenarios, to check if step definitions exist.
- During CI/CD pipeline checks, to verify step coverage without full execution.
- Before running full tests, to avoid runtime errors from missing steps.