---
title: Detection
description: Identify and prioritize unhealthy tests across your repositories.
---

Even with prevention in place, tests can degrade over time. Detection surfaces
all unhealthy tests (flaky and broken) across your repositories, so you can
see the full picture and prioritize what to fix.

{/* heading-case: allow — Detection is the name of this Test Engine page */}
## Which runs Detection reports on

Detection reports on tests that ran on your repository's
[tracked branches](/test-engine/configuration#tracked-branches), one branch at a
time: pick it in the branch selector at the top of the page. Results uploaded
from pull request branches are stored, but they do not contribute to the
metrics shown here.

A repository whose CI has only ever run on pull requests shows an empty
Detection page, even though uploads are working. Merge to a tracked branch and
the tests appear after that run completes.

Outside the dashboard, the [`mergify tests show`](/cli/tests) command reports on
the default branch: it has no flag for another one. The
[test search API](/api/test-insights) does too by default, and its
`branch_name` parameter reads any other tracked branch.

[Prevention](/test-engine/prevention) covers the pull request side of Test
Engine: it reports on tests running on pull request branches.

## How tests are classified

Mergify classifies a test from the results collected for it across CI runs:

- **Flaky**: The test's outcome does not follow from the code alone, for
  example it passed and failed on the same commit.

- **Broken**: The test failed and nothing points to flakiness.

> **Figure:** A test that both passes and fails on the same commit is flaky: its outcome does not follow from the code. One that fails from a commit on, with nothing pointing to flakiness, is broken.
>
> Grid of three tests across four CI runs on the default branch: two runs of commit a1f3, then one of b7c2 and one of c9d4. test_login passes on the first run of a1f3, fails on the second, and passes on b7c2 and c9d4: flaky. test_export passes on both runs of a1f3 and fails on b7c2 and c9d4: broken. test_signup passes on all four: healthy.

A test goes back to healthy once it passes cleanly for long enough, so a test
you fixed stops being reported without waiting for its old failures to age
out. See [Health Status](/test-engine/health) for every transition between
states.

Detection lists tests under an **Unhealthy** or a **Healthy** tab. Flaky and
broken tests share the unhealthy one, since both need attention, and the Health
column on each row tells them apart.

{/* heading-case: allow — Detection is the name of this Test Engine page */}
## Quarantine on Detection

Each test also has a **State**, shown next to its health:

- **Active**: the test's failures count in your CI outcome.

- **Quarantined**: the test still runs, but its failures no longer block
  merges.

- **Skipped**: the test does not run.

Health and state are independent: a broken test can still be active, and a
quarantined test can be healthy again. Select tests in the list to change
their state, as [Test States](/test-engine/test-states) explains.

When your subscription includes quarantine, a **Test States** card above the
list shows how many tests are quarantined, how many failures quarantine kept
from failing CI, how many pull requests it unblocked, and how quarantined tests
have been doing over time.

Next to the tabs, Detection offers a **Leftover Test States** cleanup when it
finds any: quarantined or skipped tests with no recent runs on the default
branch, often because the test was renamed or deleted. Detection cannot list a
test that does not run, so these open in the **Clean Up Test States** dialog,
where you remove the states you no longer need. A test that still exists, on
any branch, counts in your CI outcome again once no quarantine covers it, and
runs again once no skip covers it.

To find the quarantined tests that are healthy again, open the **Healthy** tab
and filter on the **Quarantined** state.

## Rerunning unhealthy tests

Mergify can rerun unhealthy tests automatically, to confirm a test really is
flaky instead of waiting for one of its ordinary runs to contradict the last
one. Reruns stay within a budget you control, which caps the extra CI time they
add.

This is opt-in per repository and requires a test framework plugin. Once a
plugin is installed, set a **Detection Budget** under
[Native Flaky Detection](/test-engine/configuration#native-flaky-detection) on
the Configuration page to enable it.

## Prioritizing with impact

The **CI Impact** column is the share of a test's executions that failed,
reported as low, medium, or high. A test that fails on most of its runs has a
higher impact than one that fails once in a while, whatever the absolute number
of failures.

Use impact to decide which tests to fix first: high-impact tests give you
the most return on investment when fixed.

## Practical workflows

### Finding your worst tests

Filter on high impact to surface the tests causing the most CI disruption.
These are the best candidates for immediate attention.

### Narrowing scope

Use filters to focus on specific areas:

- **Test**: Search for a specific test or pattern
- **Job**: Focus on tests within a particular CI job
- **Pipeline**: Narrow to a specific CI pipeline
- **CI Impact**: Keep only tests at a given impact level
- **State**: Keep only the tests in a given state

### Filtering out tests already handled

Filter on **Active** to leave out the tests your team already quarantined or
skipped, and focus on the ones that still block merges.

## Setup

Detection requires test metrics collection through repeated CI runs. See the
CI setup guides for your platform:

- [GitHub Actions setup](/ci-insights/setup/github-actions)
- [Buildkite setup](/ci-insights/setup/buildkite)
- [Jenkins setup](/ci-insights/setup/jenkins)
