Skip to content

Guide

When targeted regression testing works, and when it does not

By the CoverOps team · Last updated

Short answer

A targeted regression runs only the tests whose recorded footprint includes the changed code. It is a reasonable choice when the change is in instrumented code, the footprints are recent, new tests always run, and the full regression still runs on a schedule. When any of those fails, run the full suite.

Conditions that make it safe enough

  1. The change is code you measure. Configuration, schema migrations, infrastructure and services without instrumentation do not show up in any test's footprint.
  2. Footprints are recent. They come from each test's last recorded run. A periodic full run keeps them current.
  3. Unknown tests always run. New tests, and tests that have not run with instrumentation, have no footprint and cannot be selected on evidence.
  4. Recent failures run too. A test that failed lately should run whether or not the change reaches it.
  5. The full suite still runs. Nightly, before a release, or both. Targeting is for the fast feedback loop, not a replacement for the regression.

Where it goes wrong

  • A change alters a shared value or contract, and the code that breaks did not change itself.
  • Tests reach different code on different runs because of data, caches or timing.
  • The footprints are months old and the code paths have moved on.
  • The selection is trusted from day one, without a period of comparing it against full runs.

A safe way to adopt it

  1. Run the full suite with instrumentation for a few cycles, so every test has a footprint.
  2. Keep running the full suite, and for each change compare its failures with the tests the selection would have run. A failure outside the selection is a miss to understand.
  3. Turn targeting on for pull-request pipelines in the areas where the comparison showed no misses.
  4. Keep the full run on a schedule and before releases, and repeat the comparison from time to time.

What the saving will be

It depends on how your tests map to your code. A suite of broad end-to-end tests that each touch most services will rarely shrink much; a suite of focused tests on separable services can shrink a lot. The comparison period in step 2 is how you find out for your own suite, before you depend on it.

Sources

Check targeted runs against your own suite

In a pilot, the full suite keeps running while we measure what a targeted run would have missed.