Detection
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.
Which runs Detection reports on
Section titled Which runs Detection reports onDetection reports on tests that ran on your repository’s 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 command reports on
the default branch: it has no flag for another one. The
test search API does too by default, and its
branch_name parameter reads any other tracked branch.
Prevention covers the pull request side of Test Engine: it reports on tests running on pull request branches.
How tests are classified
Section titled How tests are classifiedMergify 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.
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 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.
Quarantine on Detection
Section titled Quarantine on DetectionEach 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 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
Section titled Rerunning unhealthy testsMergify 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 on the Configuration page to enable it.
Prioritizing with impact
Section titled Prioritizing with impactThe 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
Section titled Practical workflowsFinding your worst tests
Section titled Finding your worst testsFilter on high impact to surface the tests causing the most CI disruption. These are the best candidates for immediate attention.
Narrowing scope
Section titled Narrowing scopeUse 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
Section titled Filtering out tests already handledFilter on Active to leave out the tests your team already quarantined or skipped, and focus on the ones that still block merges.
Setup
Section titled SetupDetection requires test metrics collection through repeated CI runs. See the CI setup guides for your platform:
Was this page helpful?
Thanks for your feedback!