Skip to content

Latest commit

 

History

History
41 lines (22 loc) · 1.33 KB

012_tool.unit_tests.md

File metadata and controls

41 lines (22 loc) · 1.33 KB

Make use of unit tests

Goals

Improve code quality and enable change

Description

Manual testing is boring, error-prone, time consuming and therefore expensive. This leads to bad test coverage, bugs slipping in and people growing reluctant to changing things that already work (or seem to work).

Unit tests allow to establish trust towards a code base and enable fearless change. They can also be used to guide the creation of new APIs by providing a test bed. Automated unit tests can be nicely combined with dynamic testing tools such as Valgrind or the AddressSanitizer.

Environment

All

Platform

All

Implementation effort

Very low for green field projects. Establishing unit tests for an existing legacy code base can be a struggle.

Applicability

-

Caveats

  • Don't create tests that only run on a special target device (these are integration tests).

See also

Implementation hints

  • Don't get too orthodox about what constitutes a unit, but avoid to create tests that are actually integration tests.
  • Make sure your tests execute quickly so developers will actually run them as part of their build process.
  • Make sure individual tests are self-contained and do not rely on the post conditions of tests being executed earlier.