gurkencheck A linter for Gherkin feature files.

no-scenarios-without-when

Every scenario has to do something.

What it does#

A scenario with no When step sets the world up and checks it without ever acting on it, which usually means the action was left out, or buried in a Given where a reader will not look for it. Steps in a Background count towards this, because they really do run before the scenario; turn countBackground off if you want every scenario to read on its own instead. An And or a But counts as whatever keyword it carries on from.

Turning it on#

Add this to your .gurkencheckrc:

{
  "no-scenarios-without-when": ["on", {"countBackground": true}]
}

Settings#

SettingValueIf you leave it outWhat it does
countBackground true or false true Whether a When step in a Background counts for the scenarios under it. Set it to false to make each scenario stand on its own.

Examples#

Passes
Feature: Logging in

  Scenario: A known user logs in
    Given I am a known user
    When I log in
    Then I see my dashboard
Fails
Feature: Logging in

  Scenario: A known user has a dashboard
    Given I am a known user
    Then I see my dashboard

gurkencheck reports: Scenario "A known user has a dashboard" does not have a When step