Gherkin 구문과 기능
사람이 읽기 쉬운 Gherkin 구문을 사용하여 기능, 시나리오, Given-When-Then 단계를 정의하는 방법을 배웁니다.
Gherkin 구문과 기능은(는) CoddyKit의 무료 Testing Mastery: JUnit, Mockito & Integration Tests 강의입니다. 이것은 4개 중 2번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Testing Mastery: JUnit, Mockito & Integration Tests 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Testing Mastery: JUnit, Mockito & Integration Tests 강의에는 총 4개의 강의가 포함되어 있습니다.
이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.
Gherkin: Plain Language Tests
Gherkin is a plain-language parser used by Behavior-Driven Development (BDD) tools like Cucumber. It helps describe software behavior in a human-readable format.
This makes it easier for everyone—developers, testers, and business stakeholders—to understand and agree on what the software should do. Gherkin uses a specific set of keywords to structure these descriptions.
Defining a Feature
The Feature keyword is the starting point of any Gherkin document. It describes a high-level capability or a specific area of the application.
- Think of it as the main goal or business requirement you are testing.
- It should have a clear, concise title.
- An optional description can follow, providing more context.
- Each
.featurefile typically contains oneFeature.
Feature Example in Action
Here’s how you define a Feature. Notice the optional description lines that add clarity, explaining the 'who', 'what', and 'why'.
Feature: User Login Functionality
As a registered user
I want to log in to my account
So that I can access personalized content.Describing Scenarios
Within a Feature, individual test cases are called Scenarios. A Scenario describes a single, concrete example of behavior.
For repetitive tests with different data, Scenario Outline is used. It runs the same steps multiple times, substituting values from an Examples table (which we'll cover in future lessons).
A Simple Scenario
A Scenario typically follows the "Given-When-Then" structure. It's a specific example of how the feature behaves under certain conditions.
Feature: User Login Functionality
Scenario: Successful login with valid credentials
Given the user is on the login page
When the user enters "john@example.com" and "password123"
And clicks the "Login" button
Then the user should be redirected to the dashboard
And a welcome message "Welcome, John!" should be displayedSetting the Stage with `Given`
The Given keyword is used to describe the initial state or context of the system. It sets up the prerequisites for the scenario.
- Think of it as the "precondition" for your test.
- It should describe something that has already happened.
- Example:
Given the user is logged inorGiven a product exists with price $10.
The Action with `When`
The When keyword describes the action or event that triggers the behavior under test. This is typically an interaction by the user or an external system.
- It's the "trigger" for the behavior.
- It should describe a single, observable action.
- Example:
When the user clicks the "Add to Cart" buttonorWhen the payment is processed.
Verifying Outcome with `Then`
The Then keyword describes the expected outcome or result after the When action. It's how you verify the system's behavior.
- This is the "assertion" part of your test.
- It should describe an observable change in the system.
- Example:
Then the item should be added to the cartorThen the order status should be "Completed".
Full Gherkin Scenario
Here's a complete Scenario showing Given, When, and Then working together. Notice how And can be used to extend any step for better readability.
Feature: Shopping Cart Management
Scenario: Add item to empty cart
Given the user is on the product page for "Laptop X"
And the shopping cart is empty
When the user clicks "Add to Cart"
Then the shopping cart should contain "Laptop X"
And the cart total should be $1200.00Ordering Gherkin Steps
In Gherkin, steps follow a logical flow to describe a behavior. Arrange the keywords in the correct order for a typical scenario.
Gherkin Syntax Summary
You've learned the core elements of Gherkin syntax!
Featuredefines a high-level capability.Scenariodescribes a single example of behavior.Givensets the initial context.Whendescribes the action or event.Thenverifies the expected outcome.AndandButare used to extend steps for readability.
This human-readable language bridges the gap between technical and non-technical team members, ensuring everyone understands the desired system behavior.
자주 묻는 질문
“Gherkin 구문과 기능” 강의는 무료인가요?
네 — “Gherkin 구문과 기능” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Testing Mastery: JUnit, Mockito & Integration Tests 강의 전체를 잠금 해제할 수 있습니다. Testing Mastery: JUnit, Mockito & Integration Tests 강의에는 총 4개의 강의가 포함되어 있습니다.
“Gherkin 구문과 기능”에서 뭘 배우나요?
사람이 읽기 쉬운 Gherkin 구문을 사용하여 기능, 시나리오, Given-When-Then 단계를 정의하는 방법을 배웁니다. 브라우저에서 직접 실행하는 실습 코드로 Testing Mastery: JUnit, Mockito & Integration Tests을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.
Testing Mastery: JUnit, Mockito & Integration Tests을(를) 시작하는 데 경험이 필요한가요?
사전 경험은 필요하지 않습니다. CoddyKit의 Testing Mastery: JUnit, Mockito & Integration Tests은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 2번째 강의입니다.
“Gherkin 구문과 기능” 강의는 얼마나 걸리나요?
대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.
이 Testing Mastery: JUnit, Mockito & Integration Tests 강의에서 코드를 작성하고 실행할 수 있나요?
네. 모든 Testing Mastery: JUnit, Mockito & Integration Tests 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.
이 강의의 모든 강의
- BDD 소개
- Gherkin 구문과 기능
- 단계 정의 구현
- 시나리오 개요와 데이터 표