Slow Tests

Tests that take too long to run.

Robert C. Martin, F.I.R.S.T.

Signs of Use (Symptoms)

  • Test suite takes minutes/hours.
  • Developers skip running tests locally.

Refactoring Solution

  • Mock slow dependencies (DB, network).
  • Separate unit tests from integration tests.
  • Run fast tests frequently, slow tests in CI.

Code example

Bad

Good