12 – Make use of unit tests

Table of Contents

Make use of unit tests


Improve code quality and enable change


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.





Implementation effort

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




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

See also

Implementation hints

  • Don't get to 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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Share on facebook
Share on twitter
Share on linkedin
Share on reddit
Share on xing
Share on email
Share on stumbleupon
Share on whatsapp
Share on pocket