DEV Community

Asael Shinder
Asael Shinder

Posted on

Your Tests Take Twenty Minutes and You Have Stopped Running Them

When you joined, the test suite finished in about two minutes. Now it takes twenty. You still run it before you push, most of the time. But during the day you have started making several changes at once, running nothing, and hoping. When something fails, you spend an hour working out which of your six changes caused it.

Your tests are feedback, and like any feedback, it loses most of its value when it arrives late.

There is useful research on how waiting changes the way people work. Jakob Nielsen, building on a 1968 paper by Robert Miller, describes three rough limits. A tenth of a second feels instant. One second is about as long as you can wait without your train of thought breaking. At ten seconds, people start to drift off to other tasks. Twenty minutes is far beyond all three. Nobody sits and watches a suite that long, so they stop asking it questions.

That is the real cost. Not the twenty minutes, but the questions you no longer ask. Did this small change break anything? You would have checked in two minutes. You will not check in twenty.

So treat the slowness as a problem worth your time, not as weather.

Measure first. Most test tools can report which tests take longest. Often a handful of slow ones dominate the total, perhaps a few that start a real database or wait on a fixed timer.

Run less, more often. Most tools let you run only the tests for the file you are working on, or only those affected by your change. Keep the full suite for before you push and in the pipeline.

Look at the slowest tests one at a time. Can a sleep become a wait for a condition? Can a test that starts the whole application check the same thing at a lower level? Can tests run in parallel?

And raise it with your team, with numbers. The suite has gone from two minutes to twenty in a year, and here are the ten tests that cause half of it. That is a much easier conversation than the tests are slow.

A fast answer you check every few minutes is worth more than a perfect one you have stopped asking for.

– Asael Shinder

Top comments (0)