Given/When/Then turns a business need into a testable scenario: establish the initial context, describe the action or event, and state the expected outcome. It gives developers and testers a shared starting point for deciding what to test. section 3.1 section 9.2
Use the format to expose business behavior before implementation:
- Given a word, when it is translated into English, then return the word. section 3.1
- Given a word with extra spaces, when translating, then return the same answer as the unspaced word. section 3.1
- Given the word “hello,” when translating it to German, then the response should be “Hallo.” section 9.2
The format works at two levels. A team can use plain-language scenarios to build a unit-testing list, then use Gherkin feature files as requirements that a Go runner converts into validation criteria. The same feature can support backend, UI, and end-to-end tests. section 3.1 section 9.2
Listing 9.2 app.feature
Feature: Translation Service #1
Users should be able to submit a word to translate words within the application
Scenario: Translation #2
Given the word "hello" #3
When I translate it to "german"
Then the response should be "Hallo"
Inspect a complete Gherkin feature for a translation service, including its Feature, Scenario, Given, When, and Then lines. section 9.2

