|
| 1 | +--- |
| 2 | +title: Test Health |
| 3 | +description: "Measure the impact of flaky tests and how Test Optimization improves CI usage." |
| 4 | +further_reading: |
| 5 | +- link: "tests/flaky_test_management" |
| 6 | + tag: "Documentation" |
| 7 | + text: "Learn about managing flaky tests" |
| 8 | +- link: "tests/flaky_test_management/auto_test_retries" |
| 9 | + tag: "Documentation" |
| 10 | + text: "Learn about Auto Test Retries" |
| 11 | +- link: "tests/test_impact_analysis" |
| 12 | + tag: "Documentation" |
| 13 | + text: "Learn about Test Impact Analysis" |
| 14 | +- link: "tests/flaky_test_management/early_flake_detection" |
| 15 | + tag: "Documentation" |
| 16 | + text: "Learn about Early Flake Detection" |
| 17 | +- link: "quality_gates" |
| 18 | + tag: "Documentation" |
| 19 | + text: "Learn about Quality Gates" |
| 20 | +--- |
| 21 | + |
| 22 | +## Overview |
| 23 | + |
| 24 | +The [Test Health][5] dashboard provides analytics to help teams manage and optimize their testing in CI. This includes sections showing the current impact of test flakiness and how Test Optimization is mitigating these problems. |
| 25 | + |
| 26 | +{{< img src="tests/test-health.png" alt="Test Health dashboard" style="width:100%;" >}} |
| 27 | + |
| 28 | +## Summary metrics |
| 29 | + |
| 30 | +Based on the current time frame and filters applied, the dashboard highlights the following key metrics: |
| 31 | + |
| 32 | +- [**Pipelines Failed**](#pipelines-failed): Sum total of pipelines that failed due to flaky tests |
| 33 | +- [**Time Wasted in CI**](#time-wasted-in-ci): Total time spent in CI due to flaky tests |
| 34 | +- [**Pipelines Saved**](#pipelines-saved): How many pipelines were prevented from failing by Auto Test Retries |
| 35 | +- [**Time Saved in CI**](#time-saved-in-ci): How much time has been saved by Test Impact Analysis and Auto Test Retries |
| 36 | + |
| 37 | +### Pipelines Failed |
| 38 | + |
| 39 | +This table provides details on pipeline executions, failures, and their impact on developer experience. |
| 40 | + |
| 41 | +| Metric | Description | |
| 42 | +|--------|-------------| |
| 43 | +| **Pipeline Executions with Tests** | Number of pipeline executions with one or more test sessions. | |
| 44 | +| **Failures Due to Flaky Tests
10000
** | Number of pipeline executions that failed solely due to flaky tests. All tests that failed have one or more of the following tags: `@test.is_known_flaky` or `@test.is_new_flaky`. | |
| 45 | +| **Failures Due to Non-Flaky Tests** | Number of pipeline executions that failed due to tests without any flakiness. None of the failing tests have any of the following tags: `@test.is_known_flaky`, `@test.is_new_flaky`, and `@test.is_flaky`. | |
| 46 | +| **Dev Experience - Test Failure Breakdown** | Ratio of flaky to non-flaky test failures. When pipelines fail due to tests, how often is it a flaky test? A higher ratio of flaky test failures erodes trust in test results. Developers may stop paying attention to failing tests, assume they're flakes, and manually retry. | |
| 47 | + |
| 48 | +### Time Wasted in CI |
| 49 | + |
| 50 | +This table provides details on testing time, time lost due to failures, and the impact on developer experience. |
| 51 | + |
| 52 | +| Metric | Description | |
| 53 | +|--------|-------------| |
| 54 | +| **Total Testing Time** | Sum of the duration of all test sessions. | |
| 55 | +| **Time Lost Due to Flaky Tests** | Total duration of test sessions that failed solely due to flaky tests. All tests that failed have one or more of the following tags: `@test.is_known_flaky`, `@test.is_new_flaky`, or `@test.is_flaky`. | |
| 56 | +| **Time Lost Due to Non-Flaky Tests** | Total duration of test sessions that failed due to tests without any flakiness. All tests that failed do not have any of the following tags: `@test.is_known_flaky`, `@test.is_new_flaky`, and `@test.is_flaky`. | |
| 57 | +| **Dev Experience - Time Lost Breakdown** | Ratio of time lost due to flaky vs. non-flaky test failures. When you lose time due to tests, how much is due to flaky tests? A higher ratio of time lost to flaky test failures leads to developer frustration. | |
| 58 | + |
| 59 | +### Pipelines Saved |
| 60 | + |
| 61 | +This table shows how many pipelines [Auto Test Retries][1] have prevented from failing. |
| 62 | + |
| 63 | +<div class="alert alert-info">These metrics include test sessions in which a flaky test failed, and then was automatically retried and passed. Newer versions of test libraries provide more accurate results, as they include more precise telemetry regarding test retries.</div> |
| 64 | + |
| 65 | +| Metric | Description | |
| 66 | +|--------|-------------| |
| 67 | +| **Pipeline Executions with Tests** | Number of pipeline executions with one or more test sessions. | |
| 68 | +| **Saved by Auto Test Retries** | Number of CI pipelines with passed test sessions containing tests with `@test.is_retry:true` and `@test.is_new:false`. | |
| 69 | + |
| 70 | +### Time Saved in CI |
| 71 | + |
| 72 | +This table shows how much CI usage time [Test Impact Analysis][4] and [Auto Test Retries][1] have saved. |
| 73 | + |
| 74 | +| Metric | Description | |
| 75 | +|--------|-------------| |
| 76 | +| **Total Testing Time** | Sum of the duration of all test sessions. | |
| 77 | +| **Total Time Saved** | Sum of time saved by Test Impact Analysis and Auto Test Retries. **% of Testing Time** is the percentage of time saved out of total testing time. Total time saved can exceed total testing time if you prevent a lot of unnecessary pipeline and job retries. | |
| 78 | +| **Saved by Test Impact Analysis** | Total duration indicated by `@test_session.itr.time_saved`. | |
| 79 | +| **Saved by Auto Test Retries** | Total duration of passed test sessions in which some tests initially failed but later passed due to Auto Test Retries. These tests are tagged with `@test.is_retry:true` and `@test.is_new:false`. | |
| 80 | + |
| 81 | +## Use cases |
| 82 | + |
| 83 | +### Enhance developer experience |
| 84 | +Use **Dev Experience - Test Failure Breakdown** and **Dev Experience - Time Lost Breakdown** to identify how often flaky tests in particular cause failures and waste CI time. |
| 85 | + |
| 86 | +These Test Optimization features improve developer experience by reducing test failures and wasted time: |
| 87 | +- **[Auto Test Retries][1]** reduces the likelihood a flaky test causes a pipeline to fail. This includes your known flaky tests and flaky tests that have yet to be identified. This also provides developers with confidence in test results when a test is actually broken, as it will have failed all retries. |
| 88 | +- **[Early Flake Detection][2]**, combined with **[Quality Gates][3]**, prevents new tests that are flaky from entering your default branch. |
| 89 | +- **[Test Impact Analysis][4]** minimizes the flaky tests that run, by only running relevant tests based on code coverage. Skipping irrelevant tests also shortens the feedback loop for developers. |
| 90 | + |
| 91 | +### Maximize pipeline efficiency and reduce costs |
| 92 | +Lengthy test suites slow down feedback loops to developers, and running irrelevant tests incurs unnecessary costs. |
| 93 | + |
| 94 | +These Test Optimization features help you save CI time and costs: |
| 95 | +- **[Auto Test Retries][1]**: If a single flaky test fails during your session, the entire duration of the CI job is lost. Auto Test Retries allow flaky tests to rerun, increasing the likelihood of passing. |
| 96 | +- **[Test Impact Analysis][4]**: By running only tests relevant to your code changes, you reduce the overall duration of the test session. This also prevents pipelines from failing due to unrelated flaky tests if you skip them. |
| 97 | + |
| 98 | +## Further reading |
| 99 | + |
| 100 | +{{< partial name="whats-next/whats-next.html" >}} |
| 101 | + |
| 102 | +[1]: /tests/flaky_test_management/auto_test_retries/ |
| 103 | +[2]: /tests/flaky_test_management/early_flake_detection/ |
| 104 | +[3]: /quality_gates/ |
| 105 | +[4]: /tests/test_impact_analysis/ |
| 106 | +[5]: https://app.datadoghq.com/ci/test/health |
0 commit comments