Top Qs
Timeline
Chat
Perspective
Given-When-Then
A semi-structured way to write down test cases used for testing in software development From Wikipedia, the free encyclopedia
Remove ads
Given-When-Then (GWT) is a semi-structured way to write down test cases. They can either be tested manually or automated as browser tests with tools like Selenium and Cucumber.[1][2]
It derives its name from the three clauses used, which start with the words given, when and then.[3] Given describes the preconditions and initial state before the start of a test and allows for any pre-test setup that may occur. When describes actions taken by a user during a test. Then describes the outcome resulting from actions taken in the when clause.
The Given-When-Then was proposed by Dan North in 2006, as part of behavior-driven development.[4]
Remove ads
Example
A Given-When-Then test case for a hypothetical inventory software could be structured as follows:
GIVEN that the inventory contains 10 units of steel
AND the inventory contains 30 units of copper
WHEN we consume 2 units of steel
AND we consume 10 units of copper
AND we purchase 5 units of steel
THEN the inventory should contain 13 units of steel
AND the inventory should contain 20 units of copper
AND the purchase of 5 units of steel should be registered in the expenses list
Remove ads
See also
References
Wikiwand - on
Seamless Wikipedia browsing. On steroids.
Remove ads