Test selection

Test selection lets CI skip the tests a change cannot reach. The decision is made in CI, when a runner asks CoverOps about the change it is about to test; this screen is where you check that decision before you trust it and see what it saved once you do. Open it to turn on observation mode, to read whether selection would have missed a failure, to choose file or line granularity, to set the risk weights and read how a confidence target would fare, to set a periodic full run, and to see the test time selection saved each month.

Where to find it

Sidebar, group Analyse, Test selection (route /test-selection).

What it shows

The sections appear in this order. The window buttons at the top (7 days, 30 days, 90 days, default 30) apply to the observation report only.

Runs that used selection

Shown only once at least one run has acted on a selection answer. The latest 30 such runs, one per run key:

  • Run: the run key (links to the run's page), when the answer was given, and the baseline: base ref, merge-base sha and head sha.
  • Kind: "selected" when the runner skipped what the answer said, or "full run · <reason>" when the answer said to run everything.
  • Ran: distinct tests with a pass or fail result in that run.
  • Skipped: tests the answer allowed to skip, with "N by budget" when a time budget deferred some.
  • Failed: up to 20 failed tests, by name.
  • Test time: the summed measured duration of the tests that ran.
  • Saved: each skipped test priced at its own average measured duration in the 30 days before the answer ("—" for full runs).

Until the run's results arrive under the same run key, the row says it is waiting.

Observation report

Shown when the window holds observed runs.

The verdict line comes first:

  • No observed run has failed yet: there was nothing to miss so far, with the share of test time selection would have saved.
  • Every failure would still have run: how many failures, in how many failing runs, and the time share saved.
  • Selection would have skipped some failed tests: how many, and how many failing runs would have passed. Read the runs below before switching skipping on.

Four tiles:

  • Observed runs: runs whose results arrived; the note counts runs still waiting.
  • Failures still caught: of the tests that failed, the share selection would still have run (per-test recall).
  • Red builds still red: of the runs that had a failure, the share in which at least one failure would still have run (per-run recall).
  • Test time it would save: measured time of the tests selection would have skipped, as a share of the run's measured test time.

Then the runs table, one row per observed run key:

  • Run: run key, time, baseline, and a "full run: <reason>" badge when selection would have run everything.
  • Tests: distinct tests with a pass or fail result.
  • Would skip: how many of them were on the skip list.
  • Failed: how many failed.
  • Missed: the failed tests that were on the skip list, by name. A "budget" badge marks a test that the change did reach and only a time budget deferred. "the build would have passed" appears when every failure of that run was missed.
  • Would save: measured time of the tests on the skip list.

With fewer than 10 measured runs a note reminds you that a few runs prove little.

Start observing

Shown instead of the report when the window has no observed run. It gives one line each for GitHub Actions, pytest, JUnit/TestNG and the CLI (see How each CI client is wired). Once runs act on selection, this panel folds into Observation mode: how to turn it on.

Without agents (lite selection)

Two choices, Off (default) and On, and Always run at least (0–1000, default 10) with Save. Switching or saving needs write access to the project and is recorded in the audit log (impact.selection_lite.update). Below, the lite model's observed catch rate for the window: on observed answers that rested on history (lite or hybrid) whose results arrived, the share of red builds that would still have been red and the share of failed tests that would still have run, and how many failures were skipped on history alone. See Lite selection: how it decides, below.

In the observation table, a run whose answer rested on history carries a lite or hybrid badge, and a missed test skipped on history alone a history badge.

Selection granularity

Two choices: File (default) and Line. Click one to switch; it applies to the current project, needs write access, and is recorded in the audit log. Every project starts at File. A runner can still override it for one answer (CLI --granularity, Action input granularity).

Below the choices, measured on the file-level answers of the window whose results arrived (observed or acted on): how many test runs line level would also have skipped, their measured time against the runs' total, and how many of those tests failed. A failure there is one line level would have missed; the tests are listed as run key: suite::name. Those tests ran (file level ran them), so nothing in this line is estimated.

Targets and risk weights

  • Active target: the target of the latest recorded answer that had one (CI sets it per call), with the run key and time, and a badge when that answer allowed cutting below the floor. "None yet" until one is recorded.
  • Observed catch rate: on the failing observation-mode runs of the last 90 days ranked with the current weights (see Confidence), the share the evidence floor alone kept red, then 25%, 50% and 75% of the impacted tests' time in rank order, then the whole safe selection. With fewer than 10 such runs it says how many there are and that a confidence target runs the floor only until then. When the active target is a confidence target, the line below says the cut it picks now and that cut's observed catch rate, or that the target cannot be reached.
  • Risk weights (%): Failure rate, Change reach, Deferrals, Production use, each 0–100 with one decimal, adding up to 100; Save stays disabled until they do. Production use is 0 (off) until you set it. Reset to 50 / 35 / 15 / 0 restores the defaults. Saving needs write access to the project and is recorded in the audit log (impact.selection_weights.update).

Periodic full run

Two numbers and Save: Every N selections (0–1000) and At least every H hours (0–2160). 0 turns a rule off. The line below says "Off: selection runs everything only when it cannot decide", or which rules are on.

What selection saved

Month by month (buttons 3 months, 6 months, 12 months, default 6), counted only from runs that acted on an answer and reported their results.

Tiles:

  • Test time saved, with its share of ran plus saved time.
  • Runs: how many were selected and how many ran everything.
  • Of it, by the time budget: the saved time that came from impacted tests a budget deferred; the rest came from tests the change could not reach.
  • Failures still caught (observed): the per-test recall of observation-mode runs in the same months.

The table has one row per month: Month, Runs (with "(N full)"; hover it for the full-run reasons), Ran, Saved, Share, By budget, Observed recall.

How it is counted expands the rules, including how many runs are still waiting and how many skips could not be priced. If no run acted on selection in the period, the panel tells you how to start.

How it works

Inputs: which change, which tests

A runner sends:

  • The change. The CLI and the pytest, JUnit/TestNG, Mocha, .NET, Go, RSpec and minitest integrations compute it from a base ref: the merge base of the base ref (for example origin/main) and the change's head, then the commits from the merge base to the head, merge commits left out, at most 500. The merge base's date bounds the window CoverOps reads. On a GitHub Actions pull_request run the checked-out commit is GitHub's merge commit, which no repository holds, so its second parent (the pull request's own head) is used as the head. The base ref, merge-base sha and head sha are sent along and shown on this screen. A runner can also send the commits directly (COVERAGEOPS_SHAS, CLI --shas).
  • Candidates (optional). The runner's own list of tests, as suite::name. With candidates the answer covers exactly those tests, so a test CoverOps has never seen is in it, marked to run. Without candidates the answer covers the tests CoverOps knows, and only the skip list is safe to act on: anything not on it runs.
  • Ignore globs (optional), a target (optional) and whether it may cut below the evidence floor, the run key, and whether this is observation.

With no commits and no date, CoverOps reads the last 7 days.

Reading the change

The commits are read from the project's change sources (see Impact). Commits the date window does not hold, such as a pull request's own, are looked up by sha in the working copies and connected repositories (up to 100 per answer). Each changed file is mapped to the path your agents report it under, exactly as on Impact. A file that maps to nothing still counts: it is judged by the rules below, not read as "nothing changed".

The safe selection, test by test

Known tests are the tests with a result in the last 30 days. A test has a footprint when CoverOps holds its per-test line coverage: from the services its traffic reached (the agents attribute each request to the test it names), or recorded in the runner's own process for unit tests (pytest, Jest, Vitest, Mocha, JUnit 5/TestNG with the Java agent on the test JVM, NUnit/xUnit/MSTest with the .NET agent on the test host, go test with coverageopstest; see In-process tests). A unit test's footprint includes its per-test setup and teardown and its class's one-time setup, so a change there selects it; tests that ran at the same time in one JVM or Go test binary share their lines, which selects more, never fewer. Each test gets one decision, checked in this order:

  1. unknown (run): a candidate CoverOps cannot match to a known test. A bare name matches only if exactly one known test has it.
  2. full_run (run): the whole selection fell back to running everything (see below).
  3. failed (run): the test failed at least once in the last 30 days.
  4. impacted (run): at file granularity (the default), its footprint includes a changed file, meaning it executed at least one line of that file. At line granularity, it executed a line the change replaced, or its file fell back to file level (see Line granularity below). Each impacted test carries its evidence: the changed file, and the changed lines it ran, the function it ran, or why its file was read by file.
  5. graph_reach (run): the change touches code no test has executed, and the code map says this test runs code that depends on it.
  6. test_changed (run): the test's own source file changed. The suite is compared with the changed file name the way the integrations report it: pytest's file name, a JUnit or TestNG class (CartTest or com.shop.CartTest), a JS spec file, a .NET class (Shop.Tests.CartTests), a Go package.
  7. no_footprint (run): CoverOps has no footprint for the test.
  8. Otherwise not_impacted (skip).

A target can turn some impacted tests into over_budget skips (see Targets below).

Deleted and renamed files

A file the change deletes, or renames or moves away, is a changed file at both granularities, even when the change edits nothing else:

  • Deleted: every test whose footprint ran the file runs as impacted.
  • Renamed or moved: every test whose footprint ran the old path runs as impacted, and so does every test whose footprint already ran the new path (for example from an earlier run of the same branch). A rename that also edits the file selects the same tests; the new path is never read as code no agent measured while its old path was measured.
  • Nobody ran the old path: the old path is judged like any changed file. Measured but run by no test: it selects nothing. Never measured, or a path coverage cannot hold (a build or configuration file): the code map is asked for the tests that run code depending on it, and if it cannot place the file, everything runs (unmeasured_change). Inert files (docs, images), ignored paths and a known test's own file never force a full run, as for any other change.

Each such test's evidence names the file and what the change does to it: src/x.ts with reason deleted_file, or reason renamed with to: "src/y.ts" (or from when the test ran the new path). The CLI prints it under the summary, at file granularity too: CartTest::totals ← src/x.ts (ran it; this change renames it to src/y.ts). The run plan on Impact lists the same tests, with the file marked as deleted or renamed.

All four hosts and local working copies report deletions. Renames are reported with both paths by GitHub, GitLab, Bitbucket Cloud and local git; Azure DevOps reports a rename's old path when its change list gives one (originalPath). A source that cannot tell a rename from an added file and a deleted one reports the deletion, which selects the same tests.

Line granularity

At file granularity a test that ran any line of a changed file runs. Line granularity runs only the tests that ran a line the change replaced. It skips more, so it is riskier, and it is used only where the line mapping is exact.

How the lines are mapped. Coverage line numbers describe the build a footprint was measured on; a diff's new-side numbers describe the change's head. They meet only at the change's base. So line granularity needs the merge base (base_sha, which the CLI, the Action and the pytest/Java integrations send when they are given a base ref), composes the change's commits, oldest first, into what they do to the base (a later commit's line numbers are mapped back through the earlier ones), and reads footprints line by line only when they were measured on exactly the base commit (the run's commit sha). Hunks are exact: the context lines a provider adds around a change never count as changed.

A replaced range selects the tests that ran any of its lines at the base. Anything that cannot be mapped exactly falls back to file level for that file: every test that ran the file runs, as at file granularity.

FallbackWhen
no_baseThe caller sent no base sha (a date window has no base). Every file.
historyThe commits are not one straight line from the base to the head: a merge in between, a commit whose source gave no parents, a commit of another repository. Every file.
revision_mismatchNo footprint of the file was measured at the base commit (another revision, or a run that names no commit). When only some tests' footprints are from another revision, those tests are matched by file and counted as stale; the rest by line.
no_hunksA commit's source gave no line-level patch: Azure DevOps (it lists changed files without a patch), a binary file, a patch the provider left out as too large.
new_file, renamedThe file was added or renamed in the change. The old path of a renamed file selects whoever ran it, as at file granularity (see Deleted and renamed files).
deleted_fileThe file was deleted: whoever ran it runs, as at file granularity.
added_linesLines inserted with nothing replaced. With source indexed at the base commit (one stored version of the file, stamped with the base sha) — or, in a metadata-only project, a coverageops outline made at the base commit — the tests that ran the enclosing function run instead; otherwise the file. Method ranges an agent read from bytecode are not used for this: they miss signatures and closing braces.
deleted_linesLines removed with nothing in their place.
uncovered_changeReplaced lines no footprint at the base ran: a comment, a declaration, a constant the compiler inlines, dead code. Read as new code: the enclosing function when known, else the file.
outside_functionA change above the file's first function (from the base run's coverage), or outside every function (from indexed source): fields, constants, imports, static initialisers. Code that runs once is credited to the one test that loaded it, so its lines cannot say who depends on it.
ambiguous_pathTwo repository files map to the same coverage path.
unavailableLine granularity could not be computed; the answer is file level.

Every other rule stays as it is: failed, test_changed, no_footprint, unknown, graph_reach and every full-run reason apply at line granularity exactly as at file granularity.

What the answer says. At line granularity, granularity.files lists each changed file read line or file, with the fallback reason, the base lines that changed, how many tests it selects and how many were stale. At file granularity, granularity.shadow says how many tests line granularity would also have skipped and their measured average time (would_also_skip, would_save_ms, unpriced for tests never measured). When the answer is recorded under a run key, the shadow list is kept with it, and the Selection granularity panel measures it against the run's results.

Inert files

A change made only of these files selects nothing extra and never forces a full run:

  • prose: .md, .mdx, .markdown, .txt, .rst, .adoc
  • images: .png, .jpg, .jpeg, .gif, .svg, .webp, .ico, .bmp
  • LICENSE, LICENCE, NOTICE, CHANGELOG, AUTHORS, CODEOWNERS (with or without an extension)
  • .gitignore, .gitattributes, .editorconfig, .mailmap
  • anything under a docs/ or doc/ directory

Ignore globs add your own: ** crosses directories, * stays inside one, ? is one character, matched against the repository path.

When everything runs

The answer is a full run (mode: all), with a reason:

ReasonLabel on screenWhen
no_change_sourceno change sourceThe project has no change source, or the change could not be read at all.
source_errorsource errorA change source returned an error, so the change is not known in full.
commits_not_foundcommits not foundA commit that was asked about was not found in any source (not pushed, or in a repository that is not connected).
unmeasured_changeunmeasured changeLite selection is off, and a changed file is code no agent measured in the last 30 days, it is not inert, not ignored and not a known test's own file, and the code map cannot place it (see below). Up to 20 such files are listed.
too_much_datatoo much dataThe change overlaps 20,000 or more coverage records.
scheduled_full_runscheduledThe periodic full run is due.

Code map fallback. Before unmeasured_change, CoverOps asks the project's code map which files depend on each unmeasured file, within two hops, and keeps the dependents your agents have reported. If every unmeasured file has at least one such dependent, the tests that executed those dependents run with reason graph_reach, and no full run is needed. If any one file has none, or there is no ready map, the full run stays. The map only ever adds tests.

Lite selection: how it decides

Evidence-based selection needs agents: it skips a test only when its footprint proves it cannot see the change, and runs everything when the change touches code no agent measures. Lite selection, turned on per project, needs only test results and git. Where footprints cannot answer, it ranks tests by history, the way history-based tools (Meta's Predictive Test Selection, Launchable / CloudBees Smart Tests, Develocity Predictive Test Selection) do, but with four signals you can check against your own runs instead of a trained model:

  • Co-failures: from the failing runs of the last 60 days whose change is known, "when files under X changed, T failed". A failure counts at file level (the same file changed, weight 1), directory level (a file in the same directory, 0.5) or module level (the same first two path segments, 0.25). It counts half after 30 days, and less when the run changed many files or broke many tests at once. A test that failed and passed in the same run is not counted: a flake is not something the change caused.
  • Names and paths: the changed file and the test's suite share a stem once test affixes are stripped (BillingService ↔ BillingServiceTest, billing.py ↔ test_billing.py: score 1), or share path words (camelCase, snake and kebab split; words more than a fifth of the tests share are ignored: up to 0.7).
  • Recent failures: a test that failed in the last 30 days runs, as always; the 60-day failure rate orders the tests a target cuts and the floor.
  • Flakiness: a test's share of results that passed on retry discounts its co-failures by up to half.

The score is 1 − (1 − co-failures × flake discount) × (1 − name/path affinity), where co-failures = 1 − e^(−Σ weighted failures). A test runs on history from score 0.15; otherwise it is skipped with reason no_history_link.

Where the change of a past run comes from. First, the changed paths every recorded answer keeps (the change against its base, exact). Otherwise the run's own commit (the commit runners report with their results), read from the project's change sources and kept per project. Up to 20 unread commits are read per answer, newest failing runs first, so turning lite selection on learns from the existing history over the first answers. A commit no source has is asked again a day later.

What history judges. A test without a footprint is judged against every changed file that is not inert or ignored. A test with a footprint keeps its evidence for the files agents measure, and history judges it only against the changed files no agent measures and the code map cannot place. A change of only inert or ignored files links nothing.

The floor, never cut by a target unless allow_below_floor is set: tests that failed in the last 30 days, tests whose own file changed, new tests (first seen in the last 7 days, reason new_test), tests CoverOps has never seen (unknown), and the top of the history ranking, as many as Always run at least says, whatever their score.

In the answer. mode is still subset or all, and the skip list is what runners act on, so no runner, the Action or the CLI needs a change. New fields:

  • selection_mode: evidence (footprints only), lite (history only) or hybrid (evidence where agents measure, history elsewhere).
  • Each test's basis: evidence (its footprint or the code map), history, or rule (still failing, own file changed, new, unknown, no footprint, full run).
  • A history test's history: its score, its reasons in words ("failed 4 times in the last 60 days when src/billing/* changed", "name match: BillingService ↔ BillingServiceTest", "path match: billing, invoice (src/billing/invoice.py)") and floor: true when the floor kept it.
  • lite: what the model learned from (failing runs with a known change, how many came from answers and from commits, commits still to read, cold with fewer than 5) and what it decided (tests judged, run, skipped, kept by the floor, new).

The CLI summary says selection: lite or selection: hybrid, what the model learned from, and why each history test runs. The first version's selectors list includes history and new tests.

Targets cut history tests like impacted ones: their history score stands in for the change reach in the risk, and the floor above is kept. A confidence target learns from observed runs of lite rankings only (kept apart from evidence rankings, which order tests otherwise).

Before you skip. Turn it on with CI in observation mode and read the lite model's catch rate on the screen, and keep a periodic full run: lite answers are not exempt from it, and a full run is the only way a failure history could have missed shows up.

Periodic full run

When a rule is on and the change was read without trouble, the answer becomes a full run (scheduled_full_run):

  • At least every H hours: when there has been no full-run answer yet, or the last one is H hours old or older. Every full-run answer outside observation mode counts here, with or without a run key.
  • Every N selections: when this answer would be the Nth since the last full-run answer. This rule counts the answers runners recorded with their run key.

Any full-run answer, whatever its reason, resets the count. Observation answers are not counted and never get a scheduled full run.

Targets (optional)

A target runs less than the safe selection when CI cannot afford all of it. Give it as target (CLI --target, env COVERAGEOPS_SELECT_TARGET, Action input target); a value that cannot be read is refused with an error rather than ignored.

TargetLimit
time:<duration>, or time on its own (600 seconds, 90s, 15m, 1h30m, 500ms)at most that much test time
percent-time:<p> (40, 40%, 12.5)at most p% of the whole suite's measured test time: every test in the answer, run or skip, at its average measured duration
<p>%, 0.6, 60 (the first form)at most that share of the safe selection's own test time
confidence:<p> (90, 99.5%)the smallest risk-ranked cut of the impacted tests that kept p% of the project's failing observed runs red (see Confidence below)

time and a time-based target together: the smallest limit applies. confidence cannot be combined with time.

Durations are each test's average measured duration in the last 30 days; a test never measured is charged the median of the others (1 second when none is measured). If the whole suite must run (any full-run reason, including the periodic full run), the target is not applied and the answer says why; a time limit the safe selection already fits is not applied either. Otherwise every target cuts the same ranking:

  1. Never cut: every test that runs for a reason other than impacted (failed, test_changed, no_footprint, unknown, graph_reach).
  2. The evidence floor: the cheapest set of impacted tests that still reaches every changed line and every changed file any impacted footprint reaches, chosen greedily by most newly reached lines per millisecond (ties: the riskier test, then the name). The floor is never cut unless the request sets allow_below_floor=true (CLI --allow-below-floor, env COVERAGEOPS_SELECT_ALLOW_BELOW_FLOOR=true, Action input allow-below-floor; default false). Under a time limit the floor runs even when it exceeds the limit on its own, and the answer says so.
  3. Starved tests: a test deferred 5 or more times since it last ran (counted in the last 50 recorded select-mode answers of the last 30 days). The most deferred one runs under every target, so a target can overshoot by one test; the other starved tests go first in the fill.
  4. The fill: the remaining impacted tests by risk, then the shorter first, then by name. A time limit adds them while they fit; a confidence target keeps them up to its cut.

Risk = w₁ × failure rate (passed and failed results of the last 180 days) + w₂ × the share of the change's lines and files the test reaches + w₃ × deferrals since it last ran (5 or more counts in full) + w₄ × the share of the change's production use the test reaches. The default weights are 0.5 / 0.35 / 0.15 / 0 (those of a published industry risk model, with production use off); a project's writers change them under Targets and risk weights. The same inputs and weights always give the same ranking.

Production use (w₄, off until a writer sets it): how often production ran each changed line in the last 30 days, read from the coverage that agents in a production environment reported (prod, production, prd, live, and names like prod-eu, as the agent declared it or as its token was registered). Within a run a line counts its highest participant figure, as the run's own coverage does; runs are added up. A line weighs log(1 + hits), so a hot loop counts but cannot outweigh every other changed line; a test's share is the weight of the changed lines it reaches over that of every changed line any impacted test reaches. A changed file with no changed lines (a deletion, a rename) weighs its whole file's use. It only orders the fill: the floor, the tests that are never cut and every skip rule stay as they are, and without a target nothing changes. With it on, each impacted test in the answer carries production_hits, a deferred test's why says how often production ran the changed code it reaches, and budget.production says how many production reports the window had (reports: 0 means the weight had nothing to rank by). Only the project's own coverage is read.

Impacted tests a target cuts are skipped with reason over_budget and a why: the limit they did not fit (Over the 15m limit (time:15m); risk 0.21), the confidence cut they lie beyond, or — for a floor test cut under allow_below_floor — that it reaches changed lines no other kept test reaches and was deferred only because that was allowed. The answer's budget says the target as read (target_text), the limit, what the safe selection, the floor and the answer cost, how many tests were deferred and how many of them came from the floor (below_floor), the weights, and for a confidence target the history it used.

Confidence

A confidence target is calibrated on this project's own observation-mode runs, the only runs where every test ran and so every failure is known:

  • Every answer recorded under a run key keeps its ranking: the impacted tests in rank order, the cumulative share of their measured time after each, and where the floor ends. Answers are ranked whenever they are recorded, target or not.
  • A run's new failures are its failed tests minus the ones that ran only because they had already failed in the 30 days before the answer (those run at every cut and would make every cut look perfect). A failing run has at least one new failure.
  • Its catch depth is the smallest depth among those failures: 0 for a test that runs at any cut (own file changed, no footprint, unknown, code-map reach), its cumulative time share for an impacted test, and "never" for a test the safe selection itself skipped.
  • A cut at c (a share of the impacted tests' time, in rank order) catches a failing run when its depth ≤ c, or ≤ the end of that run's floor while the floor is protected.
  • Catch rate at c = caught failing runs ÷ failing runs. confidence:p runs the floor and the impacted tests in rank order up to the smallest c whose catch rate is ≥ p.

History is the latest observed answer per run key in the last 90 days whose results arrived, ranked with the project's current weights (after a weights change it starts again). With fewer than 10 failing runs there is not enough history: the answer falls back to the evidence floor (never below it, even with allow_below_floor), and budget.confidence.fallback is insufficient_history with a note saying how many runs there are. When even the whole safe selection caught less than p, nothing is deferred and fallback is unreachable. Keep a share of pipelines in observation mode (a nightly run is enough) so the history stays fresh.

Repeating new and changed tests (early flake detection)

When the project has early flake detection on, the answer marks the run entries of new tests (reason unknown) and of tests whose own file changed (whatever reason they run for, a full run included) with repeat: N, and adds a repeat block: count, how many tests carry it, the estimated extra_ms, max_tests, budget_ms, unknown_ms (the estimate for a test with no history) and skipped — too_many when the change has more new and changed tests than the cap (nothing repeats), over_budget with how many were left out. With it off, repeat is null. Only the repeat field is added to an entry: whether a test runs or is skipped does not change.

coverageops select --repeat-file <path> writes the repeated tests as N<TAB>suite::name lines (an empty file when none) for Playwright and Vitest, which read it from COVERAGEOPS_REPEAT_FILE; the GitHub Action does this for you and exports the variable. pytest (--coverops-select or --coverops-observe), the JUnit 5 and TestNG integrations, RSpec and minitest (COVERAGEOPS_SELECT=true or observe) read the answer themselves; the Java ones also take COVERAGEOPS_REPEAT_FILE instead of asking.

Splitting the suite into shards

A CI matrix of N jobs can share the suite by duration instead of by file count. Each job asks for its share; CoverOps deals the tests into N bins of about equal time and every job of the run gets the same plan.

  • How long a test takes. The median of its last 10 measured results on the default branch in the last 30 days (a feature branch that made it slow is not its normal); with none there, the median over every branch. A test never measured is charged the median of the measured ones, or 1 s when nothing is measured.
  • How the bins are filled. Longest first, each test into the emptiest bin (greedy longest-processing-time first). Ties go by name and by bin number, so the same tests and durations always give the same bins.
  • What is split. The runner's own list (every test on it lands in exactly one bin, known or not), or — without a list — the tests CoverOps saw a runner report in the last 30 days (tool), less the tests a selection skips. A test newer than that is in no bin; the runners place it by a hash of its name that every job computes alike, so it still runs exactly once.
  • One plan per run. The plan is kept under the run key (the CI build id by default). A job that starts late, after another job has already reported results, still reads the same bins — results arriving in between would otherwise move tests between jobs. Plans are kept for 7 days.
  • When it cannot ask. A job that cannot get the plan runs every test: slower, but no test is dropped. (Guessing locally can drop a test that every job guessed belonged to another.)
  • Each job is a part of the run. The runner plugins and the Action make job i of N part i/N of the run, and the run closes once all N have finished.
  • With selection. Split what the selection runs, not the whole suite: the runner plugins leave the skipped tests out of the split, and with the CLI you split the selection's run list.
# The runner's list in, this job's tests out (one suite::name per line).
coverageops split --shards 4 --index 2 --from-file tests.txt
# The other jobs' tests as a skip list for the runner plugins.
coverageops split --shards 4 --index 2 --from-file tests.txt --format skip > skip.txt
# Selection first, then split what it runs.
coverageops select --base origin/main --candidates tests.txt > run.txt
coverageops split --shards 4 --index 2 --from-file run.txt

--index counts from 1; COVERAGEOPS_SPLIT=2/4 stands in for --shards 4 --index 2. --by suite keeps each test file in one job. Formats: lines, skip, json.

Runner plugins split by themselves when COVERAGEOPS_SPLIT=i/N is set on the job:

RunnerWhat is splitHow the other jobs' tests are left out
Playwrightthe tests Playwright listed, by test (COVERAGEOPS_SPLIT_BY=suite: by spec file)the reporter asks before the workers start; selectionSkip(testInfo) skips them
Jestthe tests CoverOps saw Jest report, by test file (COVERAGEOPS_SPLIT_BY=test: by test)the reporter asks before the workers start; the CoverOps environment skips them
Vitestas Jestthe reporter asks in onInit; the setup file skips them
pytestthe collected tests, by test (--coverops-split-by suite: by file)deselected after collection (--coverops-split 2/4 or COVERAGEOPS_SPLIT)
JUnit 5, TestNGthe tests CoverOps saw JUnit (or TestNG) report, by test class (COVERAGEOPS_SPLIT_BY=test: by test)the JVM asks before the first test; JUnit shows them as skipped, TestNG's method interceptor leaves them out (a dependsOnMethods chain inside a class stays together; a dependency across classes or groups runs in every job)
Bazel (coverageops bazel test)the test targets that run after selection, by target (each charged the sum of its tests' durations; the labels are sent as suites)excluded from bazel test (-//pkg:t); without an answer each target goes to the shard a hash of its label picks
RSpec, minitestthe loaded tests, by test (COVERAGEOPS_SPLIT_BY=suite: by file)deselected before the run, as selection's skips are
Others (Cypress, WebdriverIO, Robot Framework)the runner's listthe CLI or the Action writes the other jobs' tests as the skip list

A runner's own sharding (--shard, pytest-split's --splits) wins: COVERAGEOPS_SPLIT is then ignored.

Observation mode and select mode

  • Observation mode: the runner asks, the answer is recorded under the run key, and nothing is skipped. When the run's results arrive under the same key, the observation report compares the skip list with what actually failed. Nothing is estimated: failures and durations come from the run itself. A test reported more than once (shards, retries) counts as failed if any report failed, with its longest duration.
  • Select mode: the runner skips what the answer allows. When it sends a run key, the answer is recorded and the run appears under Runs that used selection and in What selection saved.

For each run key only the latest answer counts. Answers are kept for 365 days.

What selection saved: the formula

  • Saved: for every run that acted on a selection and reported its results, each skipped test priced at its average measured duration in that month and the 30 days before.
  • Share = saved ÷ (ran + saved), where ran is the measured time of the tests the run actually ran.
  • Not counted: runs whose results never arrived, and skipped tests never measured. Nothing is estimated from averages across tests.
  • This is test time, not wall-clock time: tests that run in parallel still count one by one.

How each CI client is wired

Every client needs COVERAGEOPS_ENDPOINT and COVERAGEOPS_TOKEN (an agent token). The run key is COVERAGEOPS_RUN_KEY, else the CI build id (the first of GITHUB_RUN_ID, BUILD_NUMBER, CI_PIPELINE_ID, BUILD_BUILDID, CIRCLE_WORKFLOW_ID); the test results must report under the same key. The pytest, Java, Mocha, .NET, Go, RSpec and minitest integrations run the whole suite when they cannot get an answer, and the skip-file runners run everything when the file is empty or missing; the CLI exits 2 and prints nothing on stdout.

CLI

coverageops select prints a list on stdout and a summary on stderr.

  • Flags: --endpoint, --token, --base (env COVERAGEOPS_BASE), --since, --shas, --candidates FILE (or - for stdin; one suite::name per line, # comments allowed), --ignore GLOB,GLOB, --run-key, --time (env COVERAGEOPS_SELECT_TIME), --target time:15m|percent-time:40|confidence:90|60% (env COVERAGEOPS_SELECT_TARGET), --allow-below-floor (env COVERAGEOPS_SELECT_ALLOW_BELOW_FLOOR=true), --granularity file|line (env COVERAGEOPS_SELECT_GRANULARITY; leave it out to use the project's setting), --format list|names|skip|json, --observe (or COVERAGEOPS_SELECT=observe).
  • With a target, the stderr summary says the target as read, what it ran of the safe selection, how many tests it deferred (and how many from the floor), the observed catch rate of a confidence cut or why it fell back, and the first 10 deferred tests with why.
  • The stderr summary says the granularity and where it came from. At file granularity it adds what line granularity would also skip; at line granularity it lists each changed file as read by line (with the changed base lines) or by file (with the reason), and for each impacted test the changed lines it ran or its file's fallback.
  • Formats: list one selector per line, names comma-joined names for -Dtest=-style filters, skip one skippable selector per line, json the full answer.
  • A full run prints nothing for every list format, so the runner runs everything.
  • Without --candidates, list and names hold only tests CoverOps knows (impacted, failed or edited); a new test is not in them. Use --candidates or --format skip.
  • --observe prints nothing on stdout and needs a run key. Exit code 2 on bad input or when the API cannot be reached.

GitHub Action

uses: melihsakarya/coverops-action@v1 with command: select (the default), endpoint, token, and optionally base (defaults to the pull request's base branch, else the default branch), ignore, observe, time, target, allow-below-floor (default false), granularity (file or line; empty uses the project's setting), args. The Action fetches the base branch and deepens a shallow clone, installs the CLI from your CoverOps address, and sets two outputs: skip (one suite::name per line; empty means run everything) and mode (subset, all, or observe). It also writes a summary to the job, with the target and the first 10 deferred tests and why.

command: split with shards, index (from 1) and tests-file (the runner's list) or tool splits the suite for a matrix job: it sets the output tests (this job's), writes the other jobs' tests to a skip file and points COVERAGEOPS_SKIP_FILE at it (with a selection's skips added when an earlier step set one), and sets COVERAGEOPS_RUN_PART=i/N and COVERAGEOPS_RUN_PARTS=N for the later steps.

pytest

--coverops-select deselects the skip list; --coverops-observe (or COVERAGEOPS_SELECT=observe) records and deselects nothing. Also --coverops-base (env COVERAGEOPS_BASE), --coverops-ignore (env COVERAGEOPS_SELECT_IGNORE), --coverops-time, --coverops-target (any target), --coverops-allow-below-floor (env COVERAGEOPS_SELECT_ALLOW_BELOW_FLOOR); COVERAGEOPS_SHAS overrides the base. Under pytest-xdist the controller asks once and hands the list to the workers.

JUnit 5 and TestNG (Java agent)

Set COVERAGEOPS_SELECT=true (also 1, on, yes) to skip, or observe to record only; each COVERAGEOPS_* variable can also be a -Dcoverageops.* property. The change is COVERAGEOPS_SHAS or COVERAGEOPS_BASE; also COVERAGEOPS_SELECT_IGNORE, COVERAGEOPS_SELECT_TIME, COVERAGEOPS_SELECT_TARGET (any target; passed through as written). COVERAGEOPS_SELECT_ALLOW_BELOW_FLOOR=true lets a target cut the floor. The JVM asks once. JUnit shows a skipped test as disabled with the reason; TestNG leaves it out, except tests that depend on others or that others depend on. COVERAGEOPS_SKIP_FILE, when set, wins and nothing is asked. Early flake detection runs a marked or new test N times (JUnit: launched again after its class; TestNG: invocationCount) and reports it once; see Flaky tests and the Selenium JUnit and TestNG READMEs.

Mocha

--require @coverageops/mocha/register with COVERAGEOPS_SELECT=true (or observe) and COVERAGEOPS_BASE (or COVERAGEOPS_SHAS); also COVERAGEOPS_SELECT_IGNORE, COVERAGEOPS_SELECT_TIME, COVERAGEOPS_SELECT_TARGET, COVERAGEOPS_SELECT_ALLOW_BELOW_FLOOR. The main process asks once; a listed test is marked pending before the runner reaches it, so none of its hooks run, in serial and --parallel mode alike. With --forbid-pending nothing is skipped. COVERAGEOPS_SKIP_FILE, when set, wins and nothing is asked.

NUnit, xUnit, MSTest (coverageops-dotnet)

coverageops-dotnet test [dotnet test arguments] with the same variables. The answer becomes a VSTest test case filter (FullyQualifiedName!=…) in a runsettings file, so the adapters leave the tests out before discovery; your own --filter and --settings are ANDed in. A data row is left out only when its arguments are in the fully qualified name (NUnit test cases); xUnit and MSTest rows run. coverageops-dotnet filter prints the filter alone.

go test (coverageops-gotest)

coverageops-gotest [go test flags] [packages] with the same variables. It lists the packages' tests (go test -list) and passes -skip '^(TestA|TestB)$'; since -skip matches a name in every package, a name runs everywhere when any package that has it must run it. Selection works on top-level tests (subtests are part of theirs) and needs Go 1.20 or later.

Bazel (coverageops bazel test)

coverageops bazel test [bazel options] [--] <patterns> with the same variables, instead of bazel test. Bazel runs whole test targets, so selection works on targets, two ways at once:

  • The Bazel graph. The changed files since the merge base (committed, uncommitted and untracked) become labels, and bazel query 'tests(U) intersect rdeps(U, set(<files>))' (U = your patterns) names the test targets they can reach. A changed BUILD file or a deleted file takes its whole package; a change to MODULE.bazel, WORKSPACE, a .bazelrc, .bazelversion or any .bzl file makes every target affected. COVERAGEOPS_BAZEL_AFFECTED=false turns this part off.
  • CoverOps. A target whose known tests are all on the skip list is left out; a target with any test to run, or with no test CoverOps knows, runs. A test still failing keeps its target even when the graph says it is unaffected.

The left-out targets are appended to your own patterns as exclusions (bazel test … -- //... -//pkg:t), so everything else your patterns build is still built. When nothing is left, Bazel's exit 4 ("no test targets") becomes 0.

Inside a target that runs, the tests CoverOps may skip are left out with --test_filter only when you say which runner a rule kind uses and that runner can exclude: COVERAGEOPS_BAZEL_TEST_FILTER=cc_test=gtest (GoogleTest, -Suite.A:Suite.B) and java_test=junit4 (Bazel's own JUnit 4 runner). Each filtered target runs in a bazel test of its own after the main one, at most COVERAGEOPS_BAZEL_FILTER_MAX (10). It is not on by default: the JUnit 5 runner of contrib_rules_jvm and Catch2 read the same filter in another syntax, and rules_go and py_test cannot exclude.

A test is <label>::<classname>#<name> (//shop/cart:cart_test::CartTest#Adds); a target whose binary writes no XML (sh_test, a plain py_test) is one test named after the target. Tests reported under other names (an in-process agent's Class::method) are not matched to targets. Early flake detection repeats a target with --runs_per_test=<label>@N.

RSpec and minitest (coverageops-rspec, coverageops-minitest)

--require coverageops/rspec (or require "coverageops/minitest" in test_helper.rb) with the same variables, COVERAGEOPS_SKIP_FILE included. The plugin asks once, after every test file is loaded, and the skipped tests are deselected: RSpec never runs them (an exclusion filter), minitest leaves them out of runnable_methods, so none of their hooks run. Early flake detection repeats the marked and new tests in-process: RSpec runs the example again with fresh lets (as rspec-retry does), minitest runs the test again; any failed repetition fails it, and repeats says how many ran. COVERAGEOPS_SPLIT=i/N splits what the selection runs; with parallel_tests each process is a part of the run (TEST_ENV_NUMBER of PARALLEL_TEST_GROUPS).

GoogleTest (the CoverOps listener)

coverageops::gtest::InitGoogleTest(&argc, argv), or link coverageops::gtest_main, with the same variables. Before RUN_ALL_TESTS, the listener sends the binary's tests (Suite::Name) as candidates. It adds the tests it may skip to --gtest_filter as negative patterns, after your own. GoogleTest filters before any listener event, which is why this happens at initialisation. COVERAGEOPS_SPLIT=i/N adds the other shards' tests to the same filter. With GTEST_TOTAL_SHARDS set, GoogleTest's own sharding wins. The network calls go through the coverageops CLI. Without the CLI, every test runs.

CTest (coverageops ctest)

coverageops ctest -- <ctest args> with the same variables. It lists the tests with ctest --show-only=json-v1 (CMake 3.14+). A test registered by gtest_discover_tests is named Suite::Name, like the listener names it; any other test keeps its CTest name. The tests left out are passed as --exclude-from-file (CMake 3.29+, exact names). On older CMake they become an -E expression of ^name$ alternatives, joined with your -E. Past 30,000 characters, which CTest's regular expressions cannot take, everything runs.

Jest, Vitest, Playwright, Cypress

These do not ask CoverOps themselves. Write the skip list first and point COVERAGEOPS_SKIP_FILE at it:

coverageops select --base origin/main --format skip > skip.txt
COVERAGEOPS_SKIP_FILE=skip.txt npx jest

With the Action, write its skip output to the file. A missing or unreadable file means everything runs.

  • Jest: the CoverOps test environment skips listed tests as they start; test.concurrent tests are not skipped.
  • Vitest: the @coverageops/vitest/setup setup file skips listed tests in the first beforeEach.
  • Playwright: call selectionSkip(testInfo) first, in a beforeEach of its own.
  • Cypress: call selectionSkip() in the support file before labelRequests() and your own hooks; skipped tests show as pending.
  • Mocha reads the file too (above), but can also ask by itself.

The same hooks skip the other jobs' tests when the suite is split (see Splitting the suite into shards).

Metadata-only projects

A project that keeps metadata only selects tests exactly as one that stores source: selection reads coverage and git changes, never stored text. Line granularity needs method ranges at the base commit; run coverageops outline in the pipeline at the base commit (the default branch build is enough) so they exist. Without that outline, inserted lines fall back to the file with reason added_lines, as for a project with no indexed source.

What you can do

  • Switch the observation window between 7, 30 and 90 days.
  • Open a run's page from its run key.
  • Copy a Start observing line into CI.
  • Turn lite selection On or Off under Without agents (lite selection), and set Always run at least (needs write access to the project; the change is recorded in the audit log).
  • Choose File or Line under Selection granularity (needs write access to the project; the change is recorded in the audit log).
  • Set the four Risk weights and Save, or Reset to 50 / 35 / 15 / 0 (needs write access to the project; the change is recorded in the audit log).
  • Set Every N selections and At least every H hours and Save (needs write access to the project; the change is recorded in the audit log).
  • Switch What selection saved between 3, 6 and 12 months, and expand How it is counted.

Limits and good to know

  • Nothing is recorded without a run key, so such runs never appear here, and Every N selections cannot count them. At least every H hours works for them too.
  • At file granularity (the default) a test is impacted when it executed any line of a changed file. Line granularity narrows that to the changed lines only where the mapping is exact (see Line granularity); it pays off when footprints are refreshed at the commits pull requests branch from, for example a full run on every commit of the main branch.
  • The pytest, JUnit/TestNG, Mocha, .NET, Go, RSpec and minitest integrations and the skip-file runners use the project's granularity; only the CLI and the Action take a per-call override.
  • Line granularity's guard against code that runs once (static initialisers, module-level code) is the function boundary: exact with indexed source at the base, otherwise only "above the first function". A field initialised between two methods, with no indexed source, is read by line.
  • Footprints and failures are read from the last 30 days only. A test that last ran earlier is not a known test; with candidates it runs as unknown, without candidates it is simply not on the skip list.
  • If most candidates come back unknown, the runner names tests differently from its results, and nothing can be skipped. The CLI warns when more than half of 10 or more candidates are unknown.
  • A pull request with more than 100 commits that the date window does not hold ends in commits_not_found.
  • Splitting reads durations from the last 30 days. A plan made from the tests CoverOps knows does not hold a test written since; that test runs in the job its name hashes to. Jest's test.concurrent tests are not skipped, so with a split they run in every job. Vitest and Jest still load another job's test files and run their beforeAll hooks.
  • A confidence target learns only from observation-mode runs whose results arrived; a project that only acts on selection gathers no history for it. Only the CLI and the Action take a per-call --allow-below-floor/allow-below-floor; the pytest, JUnit/TestNG, Mocha, .NET, Go, RSpec and minitest integrations read COVERAGEOPS_SELECT_ALLOW_BELOW_FLOOR.
  • Lite selection is a model, not proof: a test history never saw fail with code like this change's is skipped. It learns only from failing runs whose change is known (a recorded answer, or a commit runners reported and a connected source has); with fewer than 5 such runs (cold) names, paths and the floor carry most of the answer. It reads test results, not stack traces or failure groups, and paths across several connected repositories are compared as they are.
  • In a shallow clone the base may not be reachable; the CLI then falls back to the recent window, and the pytest, Java, Mocha, .NET, Go, RSpec and minitest integrations run everything.