Introduction

Given-When-Then With Style was a series of articles published from June 2020 to May 2021, covering patterns, tips and tricks for writing executable specifications using Given-When-Then statements, then the most popular format for supporting Specification by Example.

The series of Given-When-Then With Style articles evolved through community challenges. People proposed difficult tasks they had writing scenarios. Once per week, a new community challenge went online inviting contributors to submit ideas for solving particularly tricky aspects of structuring and organising examples into scenario and feature descriptions. Members of the community wrote in with their ideas, voted for suggestions, and even published auxiliary blog posts to explain their ideas in detail. Interesting ideas and solutions were published the following week, as a summary of the challenge, along with commentary and further ideas. The community challenges were originally coordinated and edited by Gojko Adzic.

The original web site where the articles were published is no longer online, and the articles are now republished here with author’s permission. Instead of splitting challenges and solutions, the articles below provide quick access to both. Apart from that, and minor editing to update web references, the content is as when it was published.

  1. How to set up something that's not supposed to exist?
  2. How to structure a long list of examples?
  3. How to deal with pauses and timeouts?
  4. Should the feature description look like a user story?
  5. How to fix a chain of dependent scenarios?
  6. How to deal with all the extra cases and exceptions?
  7. Common preconditions: Outlines, background or hooks?
  8. How to deal with external data?
  9. How to work deal with groups of similar scenarios?
  10. How to deal with complex workflows?
  11. How to set up complex relationships?
  12. How to call one scenario from another?
  13. How to make Given-When-Then more interesting to read?
  14. How to write a good scenario title?
  15. How to choose between Given and When?
  16. How to run only a subset of scenarios from an outline?
  17. Choosing good examples: How to balance coverage, precision and clarity?
  18. How to specify relative periods?
  19. How to highlight parameters for readability?
  20. How to specify that something should be random?
  21. How to describe that a user should not be able to do something?
  22. How to specify hierarchical data?
  23. How to write good UI interaction tests?
  24. How to choose between BDD and unit tests?
  25. How to identify the intent of a confusing scenario?
  26. How to organize feature files?
  27. How to test APIs with Gherkin?
  28. Summary