Skip to content

Took the test suite to 8.9 seconds

Took the test suite from six tests over a sixty‑second limit to 135 passing in 8.9 seconds by profiling the main thread and removing the two calls it sat inside for 3,989 samples out of 4,017.

8.9 seconds for a suite that used to take sixty

Situation. The test suite had a sixty‑second time limit and six tests were over it. A test suite that takes over a minute stops being run before every change, and a suite that is not run before every change is a report on the past. The instinct in this situation is to raise the limit, and raising the limit is how a suite gets to ten minutes.

Task. The time had to be found rather than budgeted for, which meant profiling the suite instead of reasoning about which tests looked expensive.

Action. The profile was taken on the main thread while the suite ran, and the result contradicted the guess. The main thread sat inside two calls for 3,989 samples out of 4,017 — so the slow tests were not the ones doing the most work, and almost every test passed through the same two places. The first was a fixed wait used to let asynchronous work settle before asserting — a sleep, effectively, paid by every test that touched the event path whether or not the work had already finished. It was replaced by waiting on the actual condition with a timeout, so a test that is ready in five milliseconds takes five milliseconds and only a genuinely stuck test pays the full wait. The second was per‑test setup that rebuilt an expensive fixture each time, where the fixture was read‑only and could be built once for the suite. Neither was in a test anyone would have nominated as slow; both were in the shared path, which is why the whole suite was uniformly slow rather than a few tests being outliers.

Result. The suite went from six tests over sixty seconds — 74 seconds of wall clock — to 135 tests passing in 8.9, which puts it inside the window where it runs on every save. The caveat is that the shared read‑only fixture is now a coupling point — a test that mutates it will produce a failure in a different test, and the suite’s speed depends on a discipline the compiler does not enforce.

  • Lightning, lightning bolt, night
    Photo: RonBerg / Pixabay
  • Off-road vehicle raising dust at sunset
    Photo: akositim / Pixabay

Bring this experience to your project

Use “Took the test suite to 8.9 seconds” as a starting point for a similar challenge in your organisation. The services behind this work are available for your project. Tested, released and reversible, so changes reach customers on a Tuesday afternoon rather than late on a Friday night.

Explore our services Get in touch

Look behind the result

Read the situation, decisions and result in this example. We can discuss which parts transfer to your constraints and which need another approach. Took the test suite to 8.9 seconds — 8.9 seconds for a suite that used to take sixty

Explore our services Get in touch

One piece of a longer record — and it is all on this site.

Every entry is written the same way: the situation, the task, what we did and what changed.

See the whole record

Define the improvement you need

Bring the deployment path, the operational risks and the people on call. We can scope a change with checks, a recovery route and clear ownership.

See what it costs Get in touch

Is a slow test suite costing you a working day?

Ask about the decisions behind “Took the test suite to 8.9 seconds”. You will speak with the people who can explain the work and assess your own project.

Explore our services
welcome@engineer.company +45 50 10 61 84 Copenhagen, Denmark
QR code for Took the test suite from six tests over a sixty‑second limit to 135 passing in 8.9 seconds by profiling the main thread and removing the two calls it sat inside for 3,989 samples out of 4,017.
Take this page with youhttps://engineer.company/portfolio/took-the-test-suite-to-8-9-seconds/