given_when_then
This is an old revision of the document!
Table of Contents
Sources:
- Software Testing course at ITMO university by Kochubeev Nikolay Sergeevich
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 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
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.1757434443.txt.gz · Last modified: by plida
