In Agile development, the user story is a fundamental building block for delivering value to the customer. These concise descriptions of desired functionality capture the ‘who,’ ‘what,’ and ‘why’ of a feature or requirement. However, to ensure that user stories are both actionable and testable, Agile teams often employ a technique called “Give / When / Then” (GWT) acceptance criteria. This method helps to define the expected behavior of a user story in a clear and unambiguous manner.

What Are Acceptance Criteria?

Acceptance criteria are conditions or rules that a user story must meet to be considered complete. They act as a bridge between the product owner’s vision and the development team’s implementation. Essentially, they define the boundaries and expectations for each user story. Without well-defined acceptance criteria, a user story can be open to interpretation, leading to misunderstandings and potential rework.

The Structure of Give / When / Then Acceptance Criteria

Give / When / Then is a format for crafting acceptance criteria that is borrowed from Behavior-Driven Development (BDD). It encourages a more structured and understandable way of expressing the desired behavior of a user story. The format consists of three parts:

  1. Give: This section describes the initial context or state of the system. It sets the stage for the scenario you are describing. In essence, it provides the background information necessary to understand the scenario.
  2. When: This section represents the action or event that triggers the behavior described in the user story. It is the specific event that the user performs or that occurs within the system.
  3. Then: This section outlines the expected outcome or result of the action or event described in the ‘When’ section. It defines what should happen as a consequence of the action, often in terms of observable changes in the system or application.

Benefits of Give / When / Then Acceptance Criteria

  1. Clarity: The GWT format offers a structured and easy-to-understand way to express the expected behavior of a user story. This reduces ambiguity and ensures that everyone on the development team, including developers, testers, and product owners, has a clear understanding of what needs to be done.
  2. Testability: The format naturally lends itself to test cases. Each ‘Given,’ ‘When,’ and ‘Then’ component can be translated into specific test scenarios, making it easier to validate that the user story has been implemented correctly.
  3. Alignment: GWT acceptance criteria encourage collaboration between team members. Product owners, developers, and testers can work together to define and refine the criteria, ensuring that everyone is on the same page regarding the story’s scope and expectations.

Examples of Give / When / Then Acceptance Criteria

Let’s consider a simple example for an e-commerce website:

User Story: As a customer, I want to be able to add items to my shopping cart so that I can purchase them later.

Acceptance Criteria (GWT):

  • Given I am on the product page
  • When I click the “Add to Cart” button for a product
  • Then The product should be added to my shopping cart
  • And The cart icon in the navigation bar should display the updated item count
  • And I should see a confirmation message indicating the addition of the product to the cart

In this example, the acceptance criteria provide a clear understanding of what is expected from the user story, making it actionable and testable.

Problem Description Case Study:

Let’s consider a case study for a popular ride-sharing app like Uber. The problem at hand is to improve the user experience by introducing a feature that allows passengers to pre-schedule rides for specific dates and times.

User Stories with GWT Acceptance Criteria:

User Story 1: Schedule a Ride in Advance

As a passenger, I want to be able to schedule a ride for a specific date and time in advance, so that I can plan my trips better.

Acceptance Criteria (GWT):

  • Given I have the ride-sharing app installed and I’m logged in
  • When I open the app and enter my destination, date, and time for the ride
  • Then The app should display available drivers for the selected date and time
  • And I should be able to confirm and schedule the ride
  • And I should receive a confirmation notification with the details of the scheduled ride

User Story 2: Edit or Cancel a Scheduled Ride

As a passenger, I want to have the option to edit or cancel a scheduled ride, in case my plans change.

Acceptance Criteria (GWT):

  • Given I have a scheduled ride
  • When I open the app and navigate to my scheduled rides
  • Then I should see a list of my upcoming scheduled rides
  • And I should be able to select a ride to either edit the date and time or cancel it
  • And If I edit the ride, the app should show available drivers for the updated date and time
  • And I should receive a confirmation notification for any changes made

User Story 3: Notify Drivers of Scheduled Rides

As a driver, I want to receive notifications when a passenger schedules a ride with me, so that I can plan my availability.

Acceptance Criteria (GWT):

  • Given I am an active driver with the ride-sharing app open
  • When a passenger schedules a ride with me for a specific date and time
  • Then I should receive a real-time notification with the details of the scheduled ride
  • And The app should display the scheduled ride in my driver dashboard
  • And I should be able to accept or decline the scheduled ride within a reasonable timeframe

User Story 4: Provide Feedback for Scheduled Rides

As a passenger, I want to be able to provide feedback and rate drivers for scheduled rides, to help maintain service quality.

Acceptance Criteria (GWT):

  • Given I’ve completed a scheduled ride
  • When I open the app after the ride is completed
  • Then I should have the option to rate the driver and provide feedback
  • And The driver’s rating should be updated based on my feedback
  • And I should receive a thank-you message for providing feedback

These user stories and their associated Give / When / Then acceptance criteria address the problem of introducing a ride scheduling feature in a ride-sharing app. By following this structured approach, the development team can ensure a clear understanding of the requirements and the expected behavior of the new feature, ultimately leading to a better user experience.

Conclusion

Give / When / Then acceptance criteria offer a structured approach to defining the expected behavior of user stories in Agile development. By breaking down the criteria into three distinct sections – Give, When, and Then – teams can achieve greater clarity, testability, and alignment, ultimately leading to more successful product development. Incorporating this format into your Agile process can help your team deliver high-quality software that meets user expectations.

Leave a Comment