User Tools

Site Tools


given_when_then

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
given_when_then [2025/09/09 16:05] – created plidagiven_when_then [2025/09/09 16:24] (current) plida
Line 5: Line 5:
 ====== Given When Then (GWT) ====== ====== Given When Then (GWT) ======
  
-GWT is an approach to tests and scenarios which comes from BDD (Behavior-Driven Development). It helps testers, analysts and for businesses.+GWT is an approach to [[software_testing|tests]] and scenarios which comes from BDD (Behavior-Driven Development). It helps testers, analysts and for businesses.
  
 +GWT is made up of 3 parts:
  
 +  - Given: the context: pre-conditions for the behavior.
 +  - When: the behavior being described.
 +  - Then: the changes expected due to the behavior.
 +
 +==== Given ====
 +
 +  * Is a description of the prerequisites of the test.
 +  * Creates the desired system state.
 +  * Is formulated in the language of the subject area.
 +
 +==== When ====
 +
 +  * A description of one key action.
 +  * It should be clear which trigger is being checked.
 +
 +==== Then ====
 +
 +  * Description of the expected result.
 +  * The focus is on the observed behavior, not the implementation.
 +
 +
 +==== Comparing AAA and GWT ====
 +
 +[[arrange_act_assert|AAA]] and GWT are very similar:
 +
 +  * Arrange = Given.
 +  * Act = When.
 +  * Assert = Then.
 +
 +AAA is used in testing code, and GWT is used in BDD scenarios, where it's important for them to be readable for the business.
 +
 +==== Best practices ====
 +
 +  - Each test is one scenario.
 +  - Formulate Given/When/Then in terms of the subject area, not the implementation.
 +  - Use the following method names: Given_X_When_Y_Then_Z.
 +  - Avoid "and" in the sections — this is a sign that the test is too difficult.
given_when_then.1757433959.txt.gz · Last modified: by plida