xiaohongshu
xiaohongshu
gherkin-authoring
Gherkin acceptance criteria authoring. Use when writing Given/When/Then scenarios, feature files, or BDD-style specifications. Provides syntax reference, best practices, and Reqnroll integration guidance.
Full skill instructions
Gherkin/BDD acceptance criteria authoring for executable specifications.
Keywords: Gherkin, Given/When/Then, BDD, behavior-driven development, feature files, scenarios, acceptance criteria, Reqnroll, Cucumber, SpecFlow, executable specifications
Use this skill when:
Feature: <Feature Name>
<Feature description>
Background:
Given <common precondition>
Scenario: <Scenario Name>
Given <precondition>
When <action>
Then <expected outcome>
Scenario Outline: <Parameterized Scenario>
Given <precondition with <parameter>>
When <action with <parameter>>
Then <expected outcome with <parameter>>
Examples:
| parameter |
| value1 |
| value2 |
| Keyword | Purpose | Example |
|---|---|---|
Given | Setup preconditions | Given a user is logged in |
When | Describe action | When the user clicks submit |
Then | Assert outcome | Then the form is saved |
And | Additional step (same type) | And an email is sent |
But | Negative condition | But no error is shown |
Gherkin maps to the Arrange-Act-Assert pattern:
| Gherkin | AAA | Purpose |
|---|---|---|
| Given | Arrange | Set up the test context |
| When | Act | Perform the action under test |
| Then | Assert | Verify the expected outcome |
Good - One behavior:
Scenario: User login with valid credentials
Given a registered user exists
When the user enters valid credentials
Then the user is logged in
Bad - Multiple behaviors:
Scenario: User login and profile update
Given a registered user exists
When the user enters valid credentials
Then the user is logged in
When the user updates their profile
Then the profile is saved
Declarative (Preferred) - What, not how:
Scenario: Successful checkout
Given a customer with items in cart
When the customer completes checkout
Then the order is confirmed
Imperative (Avoid) - Too detailed:
Scenario: Successful checkout
Given a customer is on the home page
And the customer clicks "Products"
And the customer clicks "Add to Cart" on item 1
And the customer clicks "Cart" icon
And the customer clicks "Checkout" button
...
Use Background for common setup shared across all scenarios in a feature:
Feature: Shopping Cart
Background:
Given a customer is logged in
And the product catalog is available
Scenario: Add item to cart
When the customer adds a product to cart
Then the cart contains 1 item
Scenario: Remove item from cart
Given the cart contains a product
When the customer removes the product
Then the cart is empty
Use Scenario Outline for parameterized tests:
Scenario Outline: Validate email format
Given a user registration form
When the user enters email "<email>"
Then the validation result is "<result>"
Examples:
| email | result |
| [email protected] | valid |
| invalid-email | invalid |
| @missing-local.com | invalid |
| user@ | invalid |
Use for:
Avoid when:
Organize and filter scenarios with tags:
@smoke @authentication
Feature: User Login
@happy-path
Scenario: Successful login
...
@security @negative
Scenario: Account lockout after failed attempts
...
| Category | Examples |
|---|---|
| Priority | @critical, @high, @medium, @low |
| Type | @smoke, @regression, @e2e |
| Feature | @authentication, @checkout, @search |
| State | @wip, @pending, @manual |
| Non-functional | @security, @performance, @accessibility |
Gherkin acceptance criteria map to canonical specification:
requirements:
- id: "REQ-001"
text: "WHEN a user submits valid credentials, the system SHALL authenticate the user"
priority: must
ears_type: event-driven
acceptance_criteria:
- id: "AC-001"
given: "a registered user with valid credentials"
when: "the user submits the login form"
then: "the user is authenticated"
and:
- "a session is created"
- "the user is redirected to dashboard"
| Canonical Field | Gherkin Element |
|---|---|
acceptance_criteria.given | Given step(s) |
acceptance_criteria.when | When step(s) |
acceptance_criteria.then | Then step(s) |
acceptance_criteria.and | Additional And/But steps |
Good:
Scenario: User receives confirmation email after registration
Scenario: Cart total updates when quantity changes
Scenario: Search returns relevant results sorted by relevance
Bad:
Scenario: Test registration
Scenario: Click add button
Scenario: Verify database
Write steps that can be reused:
Reusable:
Given a user with role "<role>"
Given the user has "<count>" items in cart
When the user performs "<action>"
Not Reusable:
Given John Smith is logged in as admin
Given the user has 3 items in cart for checkout test
When the user clicks the blue submit button
Good - Behavior-focused:
When the user submits the form with invalid data
Then an error message is displayed
Bad - UI-coupled:
When the user clicks the red Submit button at the bottom
Then a red error div appears below the form
[Binding]
public class LoginSteps
{
private readonly ScenarioContext _context;
public LoginSteps(ScenarioContext context)
{
_context = context;
}
[Given(@"a registered user exists")]
public void GivenARegisteredUserExists()
{
var user = new User("[email protected]", "password123");
_context["user"] = user;
}
[When(@"the user enters valid credentials")]
public void WhenTheUserEntersValidCredentials()
{
var user = _context.Get<User>("user");
var result = _authService.Login(user.Email, user.Password);
_context["loginResult"] = result;
}
[Then(@"the user is logged in")]
public void ThenTheUserIsLoggedIn()
{
var result = _context.Get<LoginResult>("loginResult");
result.Success.Should().BeTrue();
}
}
<PackageReference Include="Reqnroll" Version="2.*" />
<PackageReference Include="Reqnroll.NUnit" Version="2.*" />
| Anti-Pattern | Problem | Fix |
|---|---|---|
| Feature-length scenarios | Hard to maintain | Split into focused scenarios |
| Imperative steps | Brittle, verbose | Use declarative style |
| Technical jargon | Not business-readable | Use domain language |
| Coupled to UI | Breaks on UI changes | Focus on behavior |
| No Background | Duplicated Given steps | Extract common setup |
| Too many Examples | Slow, redundant | Test boundary cases only |
Before finalizing a Gherkin scenario:
Detailed Documentation:
Related Skills:
canonical-spec-format - Canonical specification structurespec-management - Specification workflow navigationears-authoring - EARS requirement patternsLast Updated: 2025-12-24
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience