The Given-When-Then formula is a template intended to guide the writing of acceptance tests for a User Story:

  • (Given) some context
  • (When) some action is carried out
  • (Then) a particular set of observable consequences should obtain

An example:

  • Given my bank account is in credit, and I made no withdrawals recently,
  • When I attempt to withdraw an amount less than my card's limit,
  • Then the withdrawal should complete without errors or warnings

Tools such as JBehave, RSpec or Cucumber encourage use of this template, though it can also be used purely as a heuristic irrespective of any tool.

Agile Alliance Resources

Help Us Keep Definitions Updated

Let us know if we need to revise this Glossary Term.

  • Julian Mitchell

    I’m struggling to see the benefit of GWT statements, especially if they MUST be written, (as our current development team expect). A bulleted list of requirements seems a much cleaner and easier process, without wrapping each in a GWT statement, often stating the obvious.
    For example, a story that indicates the user wants a way to Log out of an application, would surely need an AC like ‘User can logout of the system’, which implies that 1) they are logged in and 2) they desire to log out. So surely I don’t need to write: “Given that I am a user logged in, when I wish to logout, then I can log out.”!

    • approved


      Pam Hughes

      Marketing Chief, Agile Alliance

      +1 971.204-8989 (Office)

    • Nick Ut


      I get your point that not all times GWT is the ONLY way to go forward.
      For your Example you could use GWT like ;

      Given the user is on the Application screen/page
      When the user taps/clicks on the Logout link
      Then the user must be logged out from all active sessions of the Application.

      • Julian Mitchell

        Yes it could be written like that, but it still seems overkill as its obvious they are logged in and that the sessions should shut down. Additionally, I thought AC should describe intent, not the solution.
        I took a 30 odd line bunch of GWT statements from one of our stories and converted it into a concise bullet list of business intentions, and the developers and testers were far happier with the results, and could see and understand very quickly what was required, instead of having to navigate unnecessarily verbose text.

    • Kent McDonald

      Hi Julian,
      A potential issue is that they MUST be written. Using the Given When Then format (also known as Gherkin) is a mechanism you *can* use to structure your conversation about how you expect a system to behave in specific scenarios (which is why the things you write using this format are often call examples).

      Using Given When Then is extremely helpful when you need to explore a different set of scenarios and completely extraneous when there is only one scenario and it’s clear what you want to accomplish.

      The example you described falls into the extraneous camp.

      Describing different scenarios when logging in and you provide:
      1) an unknown user name
      2) a known username and a password that does match
      3) a known username and a password that does not match

      Are cases where examples may be helpful.

      Whomever stated that GWT always has to be used may not understand the intended use, as they probably expect those things are written up by one person instead of being discussed in a three amigos fashion.