What is a .feature file?
text/plain
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 a .feature 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.
Download example .feature files
- Gherkin — Checkout Feature (Background, Outline, Doc String)The source feature for this whole group: a Background with a data table, a plain scenario, a Scenario Outline expanded by two Examples tables, and a scenario asserting against a doc string. It compiles to exactly six pickles and 32 pickle steps — the numbers the cucumber-messages and cucumber.json twins next to it report.
- Gherkin — Background, Feature Tags and HooksA named Background whose two steps are prepended to all three scenarios, plus feature-level tags that every scenario inherits and scenario-level tags that only some carry. Tag filtering is where this file earns its keep: @slow selects one scenario by its own tag and all three by inheritance from the feature.
- Gherkin — Scenario Outline with Two Examples TablesOne outline expanded by two separate Examples tables, the second of which carries its own @edge tag. Expansion must produce five scenarios, and only the two from the tagged table may match a run filtered on @edge — a distinction parsers that flatten the tables lose.
- Gherkin — Data Table and Doc String ArgumentsA step argument table with a header row, followed by two doc strings — one plain and one carrying a json content type after the opening delimiter. Doc string indentation is relative to the delimiter, so the receipt body must keep its internal column alignment while losing the six leading spaces.
- 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.
- Gherkin — French Keywords (# language: fr)A feature written entirely in French keywords, declared by the # language: fr header that must be the first line of the file. Parsers that hardcode English keywords read this as a feature with no scenarios rather than reporting an error, so it fails silently.
- Gherkin — Step Argument and Expression TypesSteps exercising every argument shape a step-definition matcher has to handle: quoted strings with escaped inner quotes, integers, decimals, a comma-and-and list, the But keyword, and angle brackets in a plain Scenario where they are literal text rather than outline placeholders.