You are reading the documentation for gurkencheck 0.0.5. Go to the latest version.

gurkencheck A linter for Gherkin feature files.

no-background-only-scenario

Drops a Background that only one scenario uses.

What it does#

A Background exists to share setup between scenarios. With only one scenario in the file there is nothing to share, and the steps read better inside the scenario. A Background inside a Rule is judged against that Rule's scenarios. A Background with no scenarios at all is left to no-files-without-scenarios to report.

Turning it on#

Add this to your .gurkencheckrc:

{
  "no-background-only-scenario": "on"
}

Settings#

This rule has no settings. Switch it on with "no-background-only-scenario": "on".

Examples#

Passes
Feature: Logging in

  Background:
    Given I am a known user

  Scenario: Logging in works
    When I log in
    Then I see my dashboard

  Scenario: Logging out works
    When I log out
    Then I see the front page
Fails
Feature: Logging in

  Background:
    Given I am a known user

  Scenario: Logging in works
    When I log in
    Then I see my dashboard

gurkencheck reports: Backgrounds are not allowed when there is just one scenario.