5 exercises — practise the English structure of Gherkin scenarios: Given/When/Then, declarative style, Background, Scenario Outlines, and avoiding common mistakes.
0 / 30 completed
1 / 30
A QA engineer is writing a Gherkin scenario for a checkout flow. Which step most correctly uses the When keyword?
When describes the action or event that triggers the behaviour being tested.
Options A, B, and C all describe states or preconditions — they correctly belong in Given clauses, not When. The Given keyword establishes context; When describes the specific trigger action; and Then describes the observable outcome. "When the user clicks the Confirm Order button" is the triggering event that causes the system to do something, making it the only correct When step here.
Key vocabulary:
• Given — establishes the initial system state or precondition before the action
• When — describes the action, event, or trigger that the scenario is testing
• Then — describes the observable outcome or expected system response
• Scenario — a single concrete example of a feature's behaviour in Gherkin
2 / 30
A Gherkin step reads: "When the user enters 'alice@example.com' into the email field, presses Tab, enters 'Secret123' into the password field, and clicks the 'Log In' button." This is an example of:
The step in the question is imperative: it describes every low-level UI action (which field, which key, which button). When the UI changes — e.g. the label "Log In" becomes "Sign in" — every scenario using this step breaks. A declarative rewrite like "When the user logs in with valid credentials" expresses business intent, is UI-independent, and remains valid as long as the login concept exists. Options A and B are incorrect. Option D confuses a screen action step with a Background precondition.
Key vocabulary:
• Declarative style — describing what the system should do, not how to interact with the UI
• Imperative style — step-by-step UI instructions coupled to the current implementation
• Brittle test — a test that breaks due to unrelated UI or code changes
• Business intent — the goal or outcome from the user's perspective, independent of implementation
3 / 30
You have 5 scenarios in a feature file that all require the same precondition: an admin user must be logged in. What is the correct Gherkin approach?
Background is Gherkin's built-in mechanism for shared preconditions — it eliminates duplication within a feature file.
Option A duplicates the step 5 times and creates a maintenance burden: change the step once and you must update all 5 scenarios. Option B is not a Gherkin pattern — there is no "setup scenario" linking mechanism. Option D conflates Scenario Outline (parameterised variation of one scenario) with shared preconditions. Option C is correct: a Background block runs its steps before each scenario in the file automatically, keeping scenarios DRY and readable — the shared precondition is maintained in one place.
Key vocabulary:
• Background — a Gherkin block whose steps run before every scenario in the feature file
• DRY (Don't Repeat Yourself) — a design principle that avoids duplicating logic or data
• Scenario Outline — a parameterised Gherkin scenario that runs once per row in an Examples table
• Feature file — the .feature file containing one feature's Gherkin scenarios
4 / 30
A QA engineer wants to test login behaviour with multiple credential combinations (valid user, invalid password, locked account). Which Gherkin structure is the most appropriate?
Scenario Outline + Examples is the correct pattern for data-driven Gherkin tests.
Option A creates three near-identical files and violates DRY — changing the scenario structure means editing three places. Option B misuses Background, which is for shared preconditions, not data variation. Option D puts multiple test cases into one Then clause, which is non-testable and violates the single-assertion principle. Option C is correct: a Scenario Outline defines the scenario structure once with angle-bracket parameters like <email>, and the Examples table provides one row per data combination — making the test readable, maintainable, and automatically parameterized by Cucumber or similar runners.
Key vocabulary:
• Scenario Outline — a Gherkin template that accepts parameters from an Examples table
• Examples table — the data table beneath a Scenario Outline that provides one test run per row
• Parameters — placeholders written as <name> in a Scenario Outline step
• Data-driven testing — running the same test logic with different input values to increase coverage
5 / 30
Which of the following Gherkin steps contains a common mistake?
A Then step must assert exactly one observable, testable outcome — not chain multiple assertions using "and".
Options A, B, and C are correct Gherkin steps: they each express one clear state, action, or outcome respectively. Option D violates two rules: first, it chains three separate assertions into one step using "and" — each should be its own separate Then or And step. Second, "the user should be happy" is not testable — it is subjective and cannot be verified by an automated or manual test. In professional Gherkin, every assertion must be observable and measurable.
Key vocabulary:
• And / But — Gherkin conjunctions that continue a Given, When, or Then block; each And must belong to one clear assertion
• Testable assertion — an outcome that can be objectively verified (page displayed, email received, status changed)
• Non-testable assertion — a subjective or ambiguous outcome that cannot be measured or automated
• Single-outcome step — the best-practice principle that each Then or And step verifies only one thing
6 / 30
Alex (Lead Developer) comments on a PR draft:
"This step isn't ideal. We need to explicitly define the *condition* that triggers the database update. Using 'Then' here is premature; we're asserting an outcome, not setting up the scenario."
The core purpose of a 'When' step in Gherkin is to *define* what happens – the action taken. Using 'Then' here prematurely checks if something happened *after* that action, which isn't how scenarios are structured. 'When' sets up the scenario, and 'Then' validates it.
7 / 30
Sarah (QA Engineer) is writing a Slack message to her team:
"I'm adding a new feature to the user profile page. I've created a Gherkin scenario using the 'Given' keyword to set up the initial state of the user data before testing the update functionality."
'Given' in Gherkin defines the initial state or preconditions required *before* any action takes place. Sarah's message accurately reflects this usage – setting up the user data before testing the update is a standard 'Given' scenario practice.
8 / 30
Mark (Developer) provides feedback on a PR description:
"The Gherkin step below doesn't fully cover the user login process. It only focuses on entering credentials; it needs to explicitly state that the system should verify those credentials."
Gherkin scenarios need to cover both *what* the user does and *what* the system does in response. Simply entering credentials isn't enough; a successful login requires verification of those credentials by the system. This missing step is a fundamental aspect of robust Gherkin development.
9 / 30
Emily (QA Lead) wants to ensure all tests related to order processing use the same initial data. Which approach is most appropriate for her?
A. Implement a separate 'Given' step for each test case.
B. Use a shared 'Given' step that sets up the common preconditions before each test.
C. Duplicate the entire Gherkin feature file for each test scenario.
D. Rely solely on the individual steps within each scenario to implicitly set up the data.
Consistency is key when writing Gherkin scenarios. A shared 'Given' step for common preconditions like an existing order or a logged-in user ensures that all tests are operating with the same initial state, preventing unexpected behavior and simplifying debugging. This approach greatly reduces redundancy.
10 / 30
David (Developer) is reviewing a Gherkin step:
"When the user clicks 'Submit' on the form."
A well-defined 'When' step in Gherkin needs to describe *both* the action taken and its potential consequence. Simply stating 'the user clicks' doesn't provide enough information for verification; it's missing a clear expectation or outcome that can be tested with 'Then'.
11 / 30
Alex (Lead Developer) comments on a PR draft:
"This step isn't ideal. We need to explicitly define the *condition* that triggers the database update. Using 'Then' here is premature; we're asserting an outcome, not setting up the scenario."
The core purpose of a 'When' step in Gherkin is to *define* what happens – the action taken. Using 'Then' here prematurely checks if something happened *after* that action, which isn't how scenarios are structured. 'When' sets up the scenario, and 'Then' validates it.
12 / 30
Sarah (QA Engineer) is writing a Slack message to her team:
"I'm adding a new feature to the user profile page. I've created a Gherkin scenario using the 'Given' keyword to set up the initial state of the user data before testing the update functionality."
'Given' in Gherkin defines the initial state or preconditions required *before* any action takes place. Sarah's message accurately reflects this usage – setting up the user data before testing the update is a standard 'Given' scenario practice.
13 / 30
Mark (Developer) provides feedback on a PR description:
"The Gherkin step below doesn't fully cover the user login process. It only focuses on entering credentials; it needs to explicitly state that the system should verify those credentials."
Gherkin scenarios need to cover both *what* the user does and *what* the system does in response. Simply entering credentials isn't enough; a successful login requires verification of those credentials by the system. This missing step is a fundamental aspect of robust Gherkin development.
14 / 30
Emily (QA Lead) wants to ensure all tests related to order processing use the same initial data. Which approach is most appropriate for her?
A. Implement a separate 'Given' step for each test case.
B. Use a shared 'Given' step that sets up the common preconditions before each test.
C. Duplicate the entire Gherkin feature file for each test scenario.
D. Rely solely on the individual steps within each scenario to implicitly set up the data.
Consistency is key when writing Gherkin scenarios. A shared 'Given' step for common preconditions like an existing order or a logged-in user ensures that all tests are operating with the same initial state, preventing unexpected behavior and simplifying debugging. This approach greatly reduces redundancy.
15 / 30
David (Developer) is reviewing a Gherkin step:
"When the user clicks 'Submit' on the form."
A well-defined 'When' step in Gherkin needs to describe *both* the action taken and its potential consequence. Simply stating 'the user clicks' doesn't provide enough information for verification; it's missing a clear expectation or outcome that can be tested with 'Then'.
16 / 30
Alex (Lead Developer) comments on a PR draft:
"This step isn't ideal. We need to explicitly define the *condition* that triggers the database update. Using 'Then' here is premature; we're asserting an outcome, not setting up the scenario."
The core purpose of a 'When' step in Gherkin is to *define* what happens – the action taken. Using 'Then' here prematurely checks if something happened *after* that action, which isn't how scenarios are structured. 'When' sets up the scenario, and 'Then' validates it.
17 / 30
Sarah (QA Engineer) is writing a Slack message to her team:
"I'm adding a new feature to the user profile page. I've created a Gherkin scenario using the 'Given' keyword to set up the initial state of the user data before testing the update functionality."
'Given' in Gherkin defines the initial state or preconditions required *before* any action takes place. Sarah's message accurately reflects this usage – setting up the user data before testing the update is a standard 'Given' scenario practice.
18 / 30
Mark (Developer) provides feedback on a PR description:
"The Gherkin step below doesn't fully cover the user login process. It only focuses on entering credentials; it needs to explicitly state that the system should verify those credentials."
Gherkin scenarios need to cover both *what* the user does and *what* the system does in response. Simply entering credentials isn't enough; a successful login requires verification of those credentials by the system. This missing step is a fundamental aspect of robust Gherkin development.
19 / 30
Emily (QA Lead) wants to ensure all tests related to order processing use the same initial data. Which approach is most appropriate for her?
A. Implement a separate 'Given' step for each test case.
B. Use a shared 'Given' step that sets up the common preconditions before each test.
C. Duplicate the entire Gherkin feature file for each test scenario.
D. Rely solely on the individual steps within each scenario to implicitly set up the data.
Consistency is key when writing Gherkin scenarios. A shared 'Given' step for common preconditions like an existing order or a logged-in user ensures that all tests are operating with the same initial state, preventing unexpected behavior and simplifying debugging. This approach greatly reduces redundancy.
20 / 30
David (Developer) is reviewing a Gherkin step:
"When the user clicks 'Submit' on the form."
A well-defined 'When' step in Gherkin needs to describe *both* the action taken and its potential consequence. Simply stating 'the user clicks' doesn't provide enough information for verification; it's missing a clear expectation or outcome that can be tested with 'Then'.
21 / 30
Alex (Lead Developer) comments on a PR draft:
"This step isn't ideal. We need to explicitly define the *condition* that triggers the database update. Using 'Then' here is premature; we're asserting an outcome, not setting up the scenario."
The core purpose of a 'When' step in Gherkin is to *define* what happens – the action taken. Using 'Then' here prematurely checks if something happened *after* that action, which isn't how scenarios are structured. 'When' sets up the scenario, and 'Then' validates it.
22 / 30
Sarah (QA Engineer) is writing a Slack message to her team:
"I'm adding a new feature to the user profile page. I've created a Gherkin scenario using the 'Given' keyword to set up the initial state of the user data before testing the update functionality."
'Given' in Gherkin defines the initial state or preconditions required *before* any action takes place. Sarah's message accurately reflects this usage – setting up the user data before testing the update is a standard 'Given' scenario practice.
23 / 30
Mark (Developer) provides feedback on a PR description:
"The Gherkin step below doesn't fully cover the user login process. It only focuses on entering credentials; it needs to explicitly state that the system should verify those credentials."
Gherkin scenarios need to cover both *what* the user does and *what* the system does in response. Simply entering credentials isn't enough; a successful login requires verification of those credentials by the system. This missing step is a fundamental aspect of robust Gherkin development.
24 / 30
Emily (QA Lead) wants to ensure all tests related to order processing use the same initial data. Which approach is most appropriate for her?
A. Implement a separate 'Given' step for each test case.
B. Use a shared 'Given' step that sets up the common preconditions before each test.
C. Duplicate the entire Gherkin feature file for each test scenario.
D. Rely solely on the individual steps within each scenario to implicitly set up the data.
Consistency is key when writing Gherkin scenarios. A shared 'Given' step for common preconditions like an existing order or a logged-in user ensures that all tests are operating with the same initial state, preventing unexpected behavior and simplifying debugging. This approach greatly reduces redundancy.
25 / 30
David (Developer) is reviewing a Gherkin step:
"When the user clicks 'Submit' on the form."
A well-defined 'When' step in Gherkin needs to describe *both* the action taken and its potential consequence. Simply stating 'the user clicks' doesn't provide enough information for verification; it's missing a clear expectation or outcome that can be tested with 'Then'.
26 / 30
Alex (Lead Developer) comments on a PR draft:
"This step isn't ideal. We need to explicitly define the *condition* that triggers the database update. Using 'Then' here is premature; we're asserting an outcome, not setting up the scenario."
The core purpose of a 'When' step in Gherkin is to *define* what happens – the action taken. Using 'Then' here prematurely checks if something happened *after* that action, which isn't how scenarios are structured. 'When' sets up the scenario, and 'Then' validates it.
27 / 30
Sarah (QA Engineer) is writing a Slack message to her team:
"I'm adding a new feature to the user profile page. I've created a Gherkin scenario using the 'Given' keyword to set up the initial state of the user data before testing the update functionality."
'Given' in Gherkin defines the initial state or preconditions required *before* any action takes place. Sarah's message accurately reflects this usage – setting up the user data before testing the update is a standard 'Given' scenario practice.
28 / 30
Mark (Developer) provides feedback on a PR description:
"The Gherkin step below doesn't fully cover the user login process. It only focuses on entering credentials; it needs to explicitly state that the system should verify those credentials."
Gherkin scenarios need to cover both *what* the user does and *what* the system does in response. Simply entering credentials isn't enough; a successful login requires verification of those credentials by the system. This missing step is a fundamental aspect of robust Gherkin development.
29 / 30
Emily (QA Lead) wants to ensure all tests related to order processing use the same initial data. Which approach is most appropriate for her?
A. Implement a separate 'Given' step for each test case.
B. Use a shared 'Given' step that sets up the common preconditions before each test.
C. Duplicate the entire Gherkin feature file for each test scenario.
D. Rely solely on the individual steps within each scenario to implicitly set up the data.
Consistency is key when writing Gherkin scenarios. A shared 'Given' step for common preconditions like an existing order or a logged-in user ensures that all tests are operating with the same initial state, preventing unexpected behavior and simplifying debugging. This approach greatly reduces redundancy.
30 / 30
David (Developer) is reviewing a Gherkin step:
"When the user clicks 'Submit' on the form."
A well-defined 'When' step in Gherkin needs to describe *both* the action taken and its potential consequence. Simply stating 'the user clicks' doesn't provide enough information for verification; it's missing a clear expectation or outcome that can be tested with 'Then'.
This exercise, "BDD Gherkin Language", tests your understanding of testing & qa lab vocabulary and phrasing through 30 multiple-choice questions drawn from real workplace scenarios.
Is this exercise free to use?
Yes. Every exercise on CoderSlingo, including this one, is completely free — no account, sign-up, or payment required.
How many questions does this exercise have?
This exercise has 30 questions. Each one presents a realistic sentence or scenario with multiple-choice options and an explanation once you answer.
What happens after I answer a question?
You'll see immediate feedback showing whether your answer was correct, along with a short explanation of why — then a button to move to the next question.
Can I retry the exercise if I get questions wrong?
Yes. Once you reach the results screen, click "Try again" to reset your answers and go through the exercise from the start as many times as you like.
Do I need to create an account to take this exercise?
No account is needed. Your answers are scored in your browser during the session — nothing is saved to a server, so you can jump straight in.
Is my progress saved if I leave the page?
No — progress within an exercise resets if you navigate away or reload. Each exercise is short enough to complete in a few minutes in one sitting.
Who is this Testing & QA Lab exercise for?
It's designed for IT professionals and learners who want to sound natural discussing testing & qa lab topics in English — useful for meetings, documentation, interviews, and day-to-day communication with English-speaking teams.
How is this different from reading a glossary or blog article?
Exercises like this one are active recall drills — you have to choose the correct term or phrasing yourself, which builds retention faster than passively reading a definition.
Where can I find more Testing & QA Lab exercises?
Browse the full Testing & QA Lab exercises hub for more practice, or explore other exercise categories covering vocabulary, grammar, interviews, and workplace communication.