Testing Types

Three types of tests:

  • Unit
  • Integration
  • Functional

Unit Tests

Unit tests are tests which test a unit of code. In Python, the unit is almost alwas a method or a function.

Python’s standard module for performing unit testing is unittest.

Integration Tests

Integration tests are tests which verify that two parts of a system are collaborating as expected.

Python’s standard module for performing unit testing is also (confusingly) unittest.

Functional Tests

Functional tests are end-to-end tests of a complete application. Also known as “system tests”.

Python does not really have a standard library for doing functional tests. I tend to use unittest.

When Do I Write Which Ones?

  • Ideally, you at two of the three: unit and functional.
  • Reasonable people can disagree on the importance of their proportions to each other within the test base of an application.
  • I tend to write mostly unit tests. I write almost no integration tests. I write a few functional tests to make sure everything is working right and that I haven’t mocked myself into placation.