Glossary · Change and test risk

What is test impact analysis?

Test impact analysis selects, for a given code change, the subset of tests that can be affected by it, and skips the rest. It maps changed lines or files to tests using recorded coverage, a dependency graph, or a trained model, so a large suite runs in minutes instead of hours on each change.

Last reviewed: November 2026

Also called Predictive test selection, Regression test selection, Test selection

In depth Diff coverage: measure and gate changed lines: how patch coverage and impacted tests work together on a pull request.

How test impact analysis works

Every approach answers the same question: given this diff, which tests could fail because of it? They differ in where the answer comes from.

MethodMapping comes fromGranularityStrengthWeakness
Coverage-map selectionA per-test coverage run that records which test ran each lineLineEvidence: a test did run the changed linesThe map goes stale and needs a coverage run with per-test data
Graph-based selectionThe call and import graph of the codeFileNeeds no test run and never goes staleAn edge says a test can reach code, not that it did
Predictive (ML) selectionA model trained on past changes and test outcomesTestCan rank by likelihood of failingA prediction, not evidence; needs history and training

A worked example. A pull request edits lines 40 to 58 of src/auth/service.py. A per-test map records that tests/test_auth.py::test_login ran those lines, so that test is selected by coverage. The graph also shows tests/test_session.py imports the file, so a graph-based tool lists it as a candidate and labels it as a weaker signal. The rest of a 4,000-test suite is skipped.

Why test impact analysis matters

Running the full suite on every change gets slower as a repository grows, and slow feedback is the reason people skip tests locally and batch changes. Selecting the tests a change reaches gives a fast first signal on the pull request, with the full suite still running on merge or on a schedule. It pairs naturally with a patch coverage gate: one says whether the changed lines are tested, the other says which tests to run to find out.

The risk is the empty answer. A selector with no data returns no tests, and a pipeline that reads that as "nothing to run" ships untested changes. Treat an unknown result as a reason to run everything.

How to select tests yourself

Without a tool, the cheap version is a path convention: run the test directory that mirrors each changed source directory.

git diff --name-only origin/main...HEAD
pytest tests/auth/ tests/session/

This misses tests that live elsewhere and tests that reach the code through other modules. For a real map in Python, record per-test coverage with pytest --cov=<package> --cov-context=test (needs pytest-cov), which records the test that ran each line.

How repowise selects tests

repowise impacted-tests diffs a change, looks up the changed lines in the per-test map, and returns the tests whose recorded coverage touches them.

repowise impacted-tests main...HEAD
repowise impacted-tests main...HEAD --format list | xargs pytest
  • Measured first: each result says how it was found. via: coverage is backed by the map; call-graph, import-graph and filename-pattern guesses appear in a separate "NOT coverage-backed" table and never pass for evidence.
  • Inferred fallback: with no map, the dependency graph says which tests reach a file, labelled inferred and never turned into a percentage.
  • Empty means unknown: an empty list never means untested. Only a selected status vouches for the list; every other status says to run the full suite.

It reports and never gates, so it exits 0 either way. Agents get the same selection as impacted_tests from the get_change_risk MCP tool. For the gating side, see diff coverage, and for the files that deserve tests first, the test coverage gap entry.

FREQUENTLY ASKED

Test impact analysis: questions

What is the difference between test impact analysis and predictive test selection?

Test impact analysis maps a change to the tests it can affect, from coverage or a dependency graph. Predictive test selection is the machine learning variant: a model trained on past runs predicts which tests are likely to fail for this change. Both skip tests, and both usually keep a periodic full run as a safety net.

Is test impact analysis safe?

It is safe when an unknown answer means running everything. The failure mode is a selector that returns an empty list because it lacks data and is read as nothing needs testing. A good tool separates a selected answer from an unknown one.

Do I need a coverage report to select tests?

A per-test coverage map gives the most precise, line-level selection. Without one, a dependency graph can still say which tests reach a changed file, but that is an inference at file level, not proof a test ran the changed lines.

How is test impact analysis different from diff coverage?

Diff coverage asks whether the lines you changed were run by tests. Test impact analysis asks which tests to run for those lines. One judges the change, the other speeds up checking it.

See it on your own repository.

Index a repository free and read the result for your own code and history. Or explore a live repo first.