Metrics and Queries for Testing
This lesson explains how to judge test results, and where to find test data.
Learning outcomes
After completing this lesson, you will be able to:
- Describe test pass rate, duration and escaped defects.
- Explain the harm that flaky tests cause.
- Identify the reports in test analytics.
- Choose a source for custom test reports.
Core testing measures
Test pass rate
Test pass rate is the percentage of tests that pass. A figure that drops suddenly usually points to a real regression, or a broken environment. A figure that wavers without code changes points to unreliable tests. The trend matters more than a single value.
Flaky test rate
A flaky test gives different results without any change to the code or environment. Flaky tests are harmful beyond the time they waste, because they teach people to re-run failures and ignore them, so that a true failure can pass unnoticed. Azure Pipelines can identify flaky tests, as the lesson on pipeline health explains.
Test duration
Duration matters because a slow test suite delays feedback. Tracking the slowest tests shows which ones to improve, parallelize or move to a later stage.
Coverage and escaped defects
Code coverage shows what the tests exercised, and it is explained in its own lesson. Escaped defects, which are the bugs found in production rather than before release, measure whether the test strategy actually works. A team with 90% coverage and a high escaped defect rate has tests that execute code without checking the right behaviour.
The following diagram follows the diagnosis of a falling pipeline pass rate from symptom to fix.

What each test measure reveals
Test analytics in Azure Pipelines
When a pipeline publishes results with the PublishTestResults@2 task or runs the VSTest task, the results appear on the Tests tab of the run. The Analytics tab of a pipeline provides reports, including Test failures, which lists the top failing tests and shows pass rate trends. Reports can be filtered by branch, test file and date range.
The Test Results Trend dashboard widget plots passed and failed tests over recent runs, and Test Results Trend (Advanced) adds more metrics, such as duration. Azure Test Plans has separate progress reports and charts for manual test suites, with test execution history and tester workloads.
Where test results appear
Querying test data
Test data is available through Analytics OData, using entity sets such as TestResultsDaily and TestRuns, and this is the usual route for Power BI reporting. A query might return the daily pass rate for one pipeline over the last 30 days. Since Analytics views do not contain test data, a requirement for a custom test report in Power BI points to an OData feed. In GitHub, results are usually added to the workflow job summary, or through a third-party action, and the Checks API can attach annotations to a pull request.
Getting test data out
Unreliable results
A pipeline's pass rate fell from 98% to 80% over a month. Developers say that re-running failed jobs usually succeeds, and code changes do not seem related. What should you do first?
Success on a re-run with the same code is the definition of flakiness. You should enable flaky test detection and use the Test failures report to find the tests that are responsible, then fix or quarantine them. Lowering the pass threshold would hide the problem, and adding retries to the whole pipeline would increase cost and hide real intermittent defects.
A team has 90% coverage and many production defects. What does this suggest?
Show answer
The tests execute code without verifying the right behaviour. Escaped defects measure effectiveness in a way that coverage does not.
Exam Tips
Remember for the exam
- Read trends; a sudden drop differs from a wavering rate.
- Escaped defects measure whether the test strategy works.
- Test results must be published to appear in the Tests tab and analytics.
- Custom test reports in Power BI use OData, not Analytics views.
- Success on a re-run with the same code indicates a flaky test.