All insights
EngineeringTesting · 5 min read

Why your test suite is slow

Every team complains about slow tests. The actual reasons are usually surprising, and the fixes don’t require throwing away the test suite.

When a test suite hits 20 minutes, everyone wants to rewrite it. When it hits an hour, it stops getting run before push. By two hours, it’s effectively been demoted to a CI nag. The pattern is universal.

Where the time usually goes

  • A handful of tests that each take a minute or more, usually integration tests with bad fixtures.
  • Database setup and teardown repeated thousands of times.
  • Tests that wait on real time (sleeps) for no good reason.
  • Tests that hit external services that don’t need to be hit.

The fix isn’t a rewrite

Profile the suite, most slowness is concentrated in a handful of tests. Fix those. Switch DB setup to once-per-suite with savepoints, not per-test. Mock the external services that don’t need to be exercised. Most teams find their suite drops from 30 minutes to 4 by fixing 1% of the tests.

Slow test suites aren’t broken everywhere. They’re broken in five specific places.

Have something that should run itself?

Tell us what runs by hand today. We reply within one business day with a first idea.