Complex Structures (Data Tables & Multi-Line Text)
You've learned to keep scenarios declarative and to parameterize them with Scenario Outlines. But some data simply doesn't fit on one line, no matter how disciplined your phrasing is. This module gives you the two tools built for exactly that problem.
Why This Module Matters
Picture a registration scenario with ten fields: first name, last name, email, password, phone, address, city, postal code, country, and a marketing-consent checkbox. Written the naive way, that's ten chained And the user enters "X" into the Y field lines before the When even happens. It's tedious to write, tedious to review, and it buries the one line that actually matters (the trigger) in a wall of near-identical noise.
The same problem shows up in a different shape when the data isn't a list of fields but a block of prose — a support ticket description, a legal disclaimer, an email body. You can't cram three paragraphs into a quoted string on one line, and you shouldn't try.
Gherkin has a dedicated answer for each shape of data:
- Data Tables — a
| key | value |grid attached directly beneath a step, for structured, multi-field data. OneGivenorWhenstep absorbs the whole table instead of spawning ten steps. - Doc Strings — a
"""triple-quoted block attached beneath a step, for free-form, unstructured text: paragraphs, comments, JSON blobs, legal text.
Neither replaces good declarative phrasing — they extend it, giving a single step a way to carry more payload than one line of English can hold.
What You'll Learn
- Why chains of near-duplicate
Andsteps are a readability and maintenance smell, not just an aesthetic annoyance - The exact syntax of a Data Table and how it attaches to the step directly above it
- When a Data Table is the right choice — structured, tabular, multi-field data — and when it's overkill for a single value
- The exact syntax of a Doc String and how it differs from a Data Table in purpose
- A decision framework for choosing between an inline parameter, a Data Table, and a Doc String
Your Practice Challenge
After the lessons, you'll take on Table or Text? — an interactive challenge with four real pieces of loan-application content (applicant details, a free-text justification paragraph, the loan amount, and pages of legal terms). For each one, you pick from a dropdown which Gherkin structure it belongs in: Data Table, Doc String, or Inline Parameter. Get all four right to unlock "Perfect Structure Choice" — misclassify just one and you'll discover a different outcome, like "Table Data Squeezed into Prose" or "Legal Text Misplaced." Six outcomes total to find.