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.
| Method | Mapping comes from | Granularity | Strength | Weakness |
|---|---|---|---|---|
| Coverage-map selection | A per-test coverage run that records which test ran each line | Line | Evidence: a test did run the changed lines | The map goes stale and needs a coverage run with per-test data |
| Graph-based selection | The call and import graph of the code | File | Needs no test run and never goes stale | An edge says a test can reach code, not that it did |
| Predictive (ML) selection | A model trained on past changes and test outcomes | Test | Can rank by likelihood of failing | A 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: coverageis 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
inferredand never turned into a percentage. - Empty means unknown: an empty list never means untested. Only a
selectedstatus 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.