Table of Contents


Dave [Thomas] is right. Code without tests, is not clean. No matter how elegant it is, no matter how readable and accessible, if it hath not tests, it be unclean. – Robert C. Martin, Clean Code, p. 9

Unit tests (aka. developer tests) are testing the correct behavior of individual parts of the source source code, e.g. classes, methods, functions or groups thereof. All not tested parts of the code are expected to work correctly.

The purpose of the unit tests is to feel confident that the code works correctly and didn't break anything (see youtube.com).

The test methods should follow the "Arrange Act Assert" pattern. The "Arrange" part sets up the test objects, "Act" performs the action to be tested and "Assert" checks that the result is correct. The sections should be separated by blank lines (see c2.com).


  • The whole test suite need to be fast so that it can be executed multiple times a day, at least before pushing it to the SCM.
  • The test need to be reliable in order to be useful.

Read more:

Test doubles

Mutation testing