User Tools

Site Tools


unit_test

This is an old revision of the document!


Unit tests

Unit tests check individual units of software (be it functions, methods or classes) in isolation from the rest of the system. The goal is to ensure that every module works as intended.

Benefits

  1. Units tests ensure quick feedback.
  2. They give confidence in refactoring.
  3. They document code's behavior.
  4. They can help find errors at the early stages.

Principles of good unit tests

  • FIRST: Fast, Isolated, Repeatable, Self-validating, Timely;
  • AAA: Arrange, Act, Assert;
  • GWT: Given-When-Then.

Pros and Cons

Pros:

  • quick feedback;
  • behavior documentation;
  • fast completion.

Cons:

  • do not test module interaction;
  • require support with changes to API;
  • do not find integration errors.
unit_test.1756905832.txt.gz · Last modified: by plida