
Unit test
Default set
Why
Find certain types of bugs as early as possible and ensure your code keeps running after a change.
How
Define one or more tests for each ‘atomic part’ of the code (e.g. a method or function). The unit should be tested in isolation.
Practice
Many companies use unit tests as part of their continuous integration environment. With every build, all unit tests are run to get an overview of the quality of the software and possible bugs. Some companies define the unit tests first and then create the code, leading to successful unit tests (Test-Driven Development).
Ingredients
- Unit test tooling (present in all modern IDEs).
- A disciplined mindset to cover all important cases.
- Special focus on calculations and more algorithmic parts of the code.
- Going well beyond the ‘happy flow’ (e.g. focus on boundary cases and exceptions).
- An upfront definition of the code coverage target for each part of the code.
Phases
- Realisation
Trade-offs
InspirationData
ExpertiseFit
OverviewCertainty
Read more about the trade-offs: Inspiration or Data / Expertise or Fit / Overview or Certainty.