Back to the glossary
Test levels and methods
Test case
A test case describes a single check: initial state, inputs or steps, and the expected result. It is the smallest plannable unit of testing.
Also known as: test scenario
Parts of a good test case
- Purpose: what is being checked, ideally linked to a requirement
- Preconditions: the state of the DUT and the environment before the test
- Steps and inputs: exactly what is done
- Expected result: how you know the test passed, as measurable as possible
- Cleanup: how the initial state is restored
Good test cases are independent
A test case should be able to run on its own, without another test first creating certain data. Dependent tests are hard to maintain and a common cause of flaky tests.
From document to code
In many teams, test cases start out in spreadsheets or test management tools and are executed by hand. With test automation, the test case itself becomes code. It is then both specification and executable check, and the two can no longer drift apart.