Practice Gherkin vocabulary: Given/When/Then structure, Feature and Scenario keywords, Scenario Outline, Background, step definitions, and Cucumber/SpecFlow conventions.
0 / 10 completed
1 / 10
In Gherkin, what does the 'Given/When/Then' structure represent?
Gherkin's Given/When/Then structure maps to test anatomy: Given sets up the initial context or precondition ('Given the user is logged in'), When describes the action or event ('When the user clicks Submit'), and Then states the expected outcome ('Then a confirmation email is sent'). This structure makes tests readable by non-technical stakeholders.
2 / 10
What does the 'Feature' keyword represent in a Gherkin file?
The Feature keyword describes the high-level software capability being specified. It's the title and description at the top of a .feature file. All scenarios in the file relate to this feature. Example: 'Feature: User registration'. The feature description provides context but is not itself executed — it's documentation.
3 / 10
What is a 'Scenario Outline' in Gherkin?
A Scenario Outline uses angle-bracket placeholders (e.g., ) and an Examples table with multiple data rows. The scenario is executed once for each row, substituting the placeholders with row values. This is the Gherkin equivalent of parameterised tests — one scenario template, multiple test cases.
4 / 10
What does the 'Background' keyword do in a Gherkin feature file?
Background in Gherkin defines common setup steps that apply to all scenarios in the file. Instead of repeating 'Given the user is logged in' in every scenario, you put it once in Background and it runs before each scenario. It keeps scenarios concise and avoids duplication.
5 / 10
'The step definition maps Gherkin to code.' What is a step definition?
Step definitions are the glue between Gherkin scenarios and executable test code. Each step definition is a function annotated with a regex or expression that matches Gherkin step text. When Cucumber/SpecFlow runs a scenario, it finds the matching step definition and executes its code. This separation allows the Gherkin to remain readable while the implementation details live in code.
6 / 10
Sarah from QA just left a comment on your pull request describing the API response. She says: 'The status code is 400 and the error message indicates 'Invalid input data'.' Which Gherkin keyword best describes Sarah's observation?
Sarah's comment highlights an API response. The 'Given/When/Then' structure is used to define a test case; however, the specific error message and status code are best represented by a 'Scenario'. A scenario outlines a particular set of steps within a feature, and this situation describes precisely that: a step with a defined outcome (400 status). Option C – 'given' – sets up the initial state but doesn't capture the observed result.
7 / 10
You are writing a Gherkin feature for a new user registration flow. You want to ensure that every scenario in this feature starts with the same initial setup – creating a new user account with a specific email address. Which keyword is most appropriate for defining this common setup across all scenarios?
The 'Background' keyword is used to define common setup steps that should be executed before each scenario in a feature. This ensures consistency and avoids repetition within individual scenarios. Options B, C, and D relate to other Gherkin concepts – steps are actions *within* a scenario, examples vary scenarios, and the 'feature' defines the overall purpose.
8 / 10
During a standup meeting, you're explaining your work on implementing user authentication. You say: 'I've written Gherkin steps to verify that users can successfully log in with valid credentials and also that the system correctly handles invalid login attempts.' Which aspect of Gherkin are you primarily discussing?
You're describing the process of mapping Gherkin steps (the 'Given/When/Then') to executable code. A 'step definition' is the crucial link between the human-readable Gherkin and the automated tests. Options A, B, and C are all valid Gherkin concepts, but this question specifically asks about *linking* them.
9 / 10
You're reviewing a PR that includes a new Gherkin feature for processing payments. The PR description contains the following: 'This feature implements the payment flow, ensuring transactions are processed correctly and errors are handled gracefully.' Which of the following best describes the primary purpose of this text?
The text provides a concise description of the 'Feature' itself. A feature description explains what the feature does and its intended behavior. This is crucial for other developers to understand the purpose of the Gherkin files and the associated automated tests. Options A, B, and C are all elements that could be *within* a feature description.
10 / 10
You're collaborating with another developer on a new API endpoint. He provides you with the following Gherkin step: `Given I am logged in as 'john.doe'@example.com When I request /users/{user_id} Then the user details should be returned`. What does this step primarily represent?
This step represents a *single* action – 'request /users/{user_id}' – that is part of a larger test scenario. It follows the standard Gherkin 'Given/When/Then' pattern, where 'Given' sets up the initial context (logged in as a specific user), and 'When' describes the action performed. Options A, B, and D are broader Gherkin concepts; this is a granular step definition.
What will I learn from the "Gherkin Vocabulary" exercise?
Practice Gherkin vocabulary: Given/When/Then structure, Feature and Scenario keywords, Scenario Outline, Background, step definitions, and Cucumber/SpecFlow conventions.
Is this exercise free to use?
Yes. Every exercise on CoderSlingo, including this one, is free to use with no account, sign-up, or paywall required.
How many questions are in this exercise?
This set contains 10 multiple-choice questions, each with a detailed explanation shown after you answer.
Do I need to create an account to track my progress?
No account is required. Your progress bar and score reset each time you reload the page, but you can retry the exercise as many times as you like.
Who is this TDD/BDD Language exercise for?
This exercise is built for IT professionals and non-native English speakers who need to read, write, and discuss tdd/bdd language topics confidently at work.
What happens if I answer a question incorrectly?
You will see the correct answer highlighted along with a detailed explanation of why it is correct -- so every wrong answer becomes a learning moment, not just a lost point.
Can I retry this exercise?
Yes -- click "Try again" on the results screen at any time to reset your score and go through all the questions again.
How long does this exercise take to complete?
Most learners finish all 10 questions in under 10 minutes, since each question is answered by clicking a single option.
Where can I find more TDD/BDD Language exercises?
See the full TDD/BDD Language exercises hub for more vocabulary drills on this topic.
Is this exercise mobile-friendly?
Yes -- the exercise works on any device with a modern browser, including phones and tablets, with no app download required.