Skip to content
Novus Examples
feature722 B

Gherkin — Rule Keyword (Gherkin 6)

Two Rule blocks, the first with its own Background that applies only to the examples inside it. Parsers written before Gherkin 6 either reject Rule outright or, worse, hoist the Background to the whole feature and add a step to the third example that was never there.

Preview — first 25 linesfeature
Feature: Free shipping

  Rule: Orders over 50.00 ship free

    Background:
      Given the free-shipping threshold is 50.00

    Example: An order above the threshold ships free
      Given a cart subtotal of 62.40
      When I view the shipping cost
      Then the shipping cost is 0.00

    Example: An order below the threshold pays shipping
      Given a cart subtotal of 49.99
      When I view the shipping cost
      Then the shipping cost is 4.95

  Rule: Digital-only orders never pay shipping

    Example: A digital-only cart ships free at any subtotal
      Given a cart containing only digital items
      And a cart subtotal of 3.00
      When I view the shipping cost
      Then the shipping cost is 0.00

Specifications

Seed
61200
Encoding
UTF-8
Line Endings
LF
Gherkin Dialect
en
Rules
2
Examples
3
Backgrounds
1
Background Scope
first Rule only
Gherkin Version
6+
Example Keyword
Example (synonym of Scenario)

Testing contract

Expected to pass
Scenario
Parse a feature that groups examples under Rule blocks with a rule-scoped Background.
Expected result
Three examples are found across two rules; the first two carry the Background step and the third does not.

What is a .feature file?

A .feature file holds a Gherkin specification: a business-readable, plain-text description of behaviour written as Feature, Background, Scenario, and Scenario Outline blocks whose steps begin with Given, When, Then, And, or But. Scenario Outlines are parameterised by an Examples table, and tags such as @smoke mark subsets of the suite. Cucumber, Behave, SpecFlow, and Behat all read the same grammar, with localised keyword sets available for non-English specifications.

How to use this file

Use an example .feature file to test Gherkin parsers, step-definition matchers, linters, and editor tooling — verifying tag inheritance, Scenario Outline expansion against the Examples table, docstring and data-table arguments, and behaviour on deliberately malformed keywords.

How to use this file for testing

“Gherkin — Rule Keyword (Gherkin 6)” is a deterministic Novus Examples fixture for Code parsing, Conversion testing, Editor testing. Short, known-correct source files in many languages with classes, functions, generics, enums, and error handling — for testing parsers, linters, formatters, language detection, and diff viewers.

Documented properties for this file: seed 61200 · UTF-8 · LF. Compare results against paired or grouped companions on this page when present (clean↔damaged, searchable↔scanned, or format twins) so scores stay reproducible across runs.

Download the file once, keep the path stable in CI or local scripts, and treat the spec table as the contract: dimensions, seeds, field lists, and roles are intentional. Corrupt or invalid samples are labelled as such — expect parsers to fail loudly rather than silently accept them.

Test and coverage reports document their totals (suites, cases, passes, failures, skips, covered lines) in the spec table. Point your CI dashboard, coverage gate, or report converter at the file and assert those counts survive; format twins carry identical numbers so a conversion can be scored exactly.

Generated by generation/testing.py. Free for any use, no attribution required — license.