Skip to main content

What is Strict in Cucumber

Note: Earlier Cucumber other implementation except Cucumber-JVM default to --non-strict mode. With version 6, Cucumber-JVM will default to --strict mode. More Information Here: Cucumber 6 default to --strict mode

Using the --strict flag will cause cucumber to fail unless all the step definitions have been defined. 

strict = false in cucumber

false: If strict option is set to false then at execution time if cucumber encounters any undefined/pending steps then cucumber does not fail the execution and undefined steps are skipped and BUILD is SUCCESSFUL and

strict = true in cucumber

true: if Strict option is set to true then at execution time if cucumber encounters any undefined/pending steps then cucumber does fails the execution and undefined steps are marked as fail and BUILD is FAILURE.

Cucumber Option Strict Example

package com.pb.cucumbertest.stepdefinitions;

import org.junit.runner.RunWith;

import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;

		plugin = {"pretty", "html:target/cucumber"},
		features = {"features"},
		strict = true

public class Runner {

  • Method Signature: public abstract boolean strict
  • Returns: true if strict mode is enabled (fail if there are undefined or pending steps)
  • Default: false

Consider below feature file, Here step definition is defined with Given step and step definition is not defined with for When step.

Feature: Search Feature
  Scenario: Title of your scenario
    Given I am on the home page
    When I fill in "search" with "xyz"

Output in JUnit section when Strict is true

io.cucumber.junit.UndefinedThrowable: The step "I fill in "search" with "xyz"" is undefined

Output when Strict is false

You will see when strict is set to false, even when step does not exist; it will not throw any error.

Video Tutorial: Strict in Cucumber

Submitted by tgoswami on August 30, 2020

Tarun has 11+ years of experience in Quality Assurance in different domains like Banking, E-commerce, Health and Education.


At ProgramsBuzz, you can learn, share and grow with millions of techie around the world from different domain like Data Science, Software Development, QA and Digital Marketing. You can ask doubt and get the answer for your queries from our experts.