Unit tests rules

Unit and integration testing best practices

Clean unit tests - tests that focus in single component, and isolation from other components.

  1. Keep the test fast - 1 second, avoid communicating with external services and databases. We can use Record and Playback Proxy (API, Recorded Response, VCR.PY)
  2. Single assertion per test
  3. Keep tests isolated and focused on one thing only (so if the tests fails, you can quickly find the cause of the failure)
  4. Independent - we should able to run any test independently and randomly
  5. Code should not be duplicated, DRY tests (use parametrized or fixture)
SuperMade with Super