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
- The change is code you measure. Configuration, schema migrations, infrastructure and services without instrumentation do not show up in any test's footprint.
- Footprints are recent. They come from each test's last recorded run. A periodic full run keeps them current.
- Unknown tests always run. New tests, and tests that have not run with instrumentation, have no footprint and cannot be selected on evidence.
- Recent failures run too. A test that failed lately should run whether or not the change reaches it.
- 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
- Run the full suite with instrumentation for a few cycles, so every test has a footprint.
- 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.
- Turn targeting on for pull-request pipelines in the areas where the comparison showed no misses.
- 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.