Writing Effective User Stories: From INVEST to Gherkin

Chatchawal I
Tri Petch Digital
Published in
3 min readMay 8, 2024

User stories are the core principles and values of Agile software development. It helps teams understand customer needs and drive the development process in a user-centric way. This post will explore how to craft these stories to maximize clarity and effectiveness using the INVEST criteria and Gherkin syntax.

What are User Stories?

User stories articulate what a user needs from the system and why. They are short, simple descriptions told from the user’s perspective. Well-written stories help ensure that the product delivers value to the customer.

The Power of INVEST

The INVEST acronym helps ensure that each user story is well-crafted. Each letter stands for a key attribute of a good story:

  • Independent: Minimize dependencies to allow more flexibility in planning and implementation.
  • Negotiable: Open to discussion and refinement. They are not final specs but a collaboration tool.
  • Valuable: Provides value to the end user, not just an internal artifact or a piece of code.
  • Estimable: Clear enough that developers can estimate how much effort is involved.
  • Small: Small enough to be completed in one sprint, facilitating smoother planning and review.
  • Testable: Defined well enough that the team can create tests to verify the functionality.

Gherkin Syntax: Bridging Stories and Testing Gherkin, a language used to write test cases, can refine user stories by defining clear acceptance criteria. It uses a structured format:

  • Given some initial context (the beginning state)
  • When some action is carried out
  • Then a particular set of observable outcomes should obtain

Example of a User Story with Gherkin Syntax:

Title: User adds an item to their shopping cart

As a customer,

I want to be able to add a product to my shopping cart

So that I can manage my purchases before checking out.

Acceptance Criteria:

Scenario: Customer adds an available item to the shopping cart
Given the customer is logged in and on the product detail page
When the customer clicks on "Add to Cart" button
Then the item should be added to their shopping cart
And the cart's item count should increase by 1

Scenario: Customer adds an out-of-stock item to the shopping cart
Given the customer is logged in and on the product detail page
When the customer attempts to add an out-of-stock item to the cart
Then an error message "Sorry, this item is currently out of stock" should be displayed

Utilizing Gherkin enhances team communication, ensuring everyone understands what is being built and how it will be tested.

Writing effective user stories is crucial for the success of Agile projects. By adhering to the INVEST criteria and employing Gherkin syntax for acceptance criteria, teams can ensure clearer communication, better planning, and higher product quality.

Refine your ability to write good user stories as a PO or Agile team member, and your products will be significantly impacted.

--

--