Unit Test 101

Verify in this order when possible (from the simplest to the more complex):

  1. return value or exception
  2. change in state
  3. interaction with external component

Usually chicken counting is enough: zero, one, many.

Cyclomatic complexity of the test should be 1.

From Dave Farley: The 3 Types of Unit Tests in TDD (video).

Page Metadata

Source: unit-test.md Created: 2023-09-29T10:38:26+03:00 Changed: 2023-09-29T10:38:26+03:00