Quality Metrics and Test Reporting Questions
Defining, computing, and communicating software quality. Covers choosing meaningful quality and test metrics (defect escape rate, defect detection effectiveness, defect density, MTTD/MTTR, pass rate, regression frequency, automation suite health and maintenance cost) versus vanity numbers; baselining, trend interpretation (real change versus normal variation), and alert thresholds; dashboards, weekly stability reports, and release-quality reports for engineering, product, and executive audiences, including composite go/no-go scores; framing unfavourable results; guarding against gamed metrics and reading what numbers such as code coverage or a high pass rate hide; investigating contradictory or shifting metrics and testing whether a quality signal really predicts customer outcomes; metric definitions, ownership, and governance; computing metrics from test-run and bug-tracker data (SQL and scripts); designing test-results reporting pipelines, storage schemas, real-time versus batch reporting, alerting, and failure fingerprinting and grouping for triage; and tying quality signals to product and business outcomes. Deciding what to automate and diagnosing individual flaky tests are covered elsewhere.
Tell me about a time you built or improved a test-reporting dashboard or automated summary. Which metrics did you put on it, which did you leave off, and what changed as a result?
Sample Answer
Direct answer
I turned a nightly "wall of red" into a one-screen summary that showed failures grouped by root cause instead of one row per failing test. The result was that people reviewed a handful of causes each morning instead of hundreds of individual failures, and the team started fixing causes instead of re-running builds. (Below is a story skeleton; swap in your own real numbers, but keep the shape.)
Situation and task
- Our CI (continuous integration, the automated build-and-test system) ran about 2,000 automated tests overnight. The default report was a flat list of failing test names, so on a bad night 240 tests failed and nobody could tell whether that was 240 problems or one.
- I was asked to make the report usable for QA, developers and the engineering manager, who each wanted something different.
Action: metrics I put on it (each tied to a decision)
- Failures grouped by signature (a signature is a short fingerprint of a failure's error and location, so identical failures group together). Decision: which cause to fix first.
- Pass rate on the main branch only (the trunk, the shared branch releases are cut from), trended over 14 days. Decision: is the trunk healthy enough to release from?
- Flake rate per test (a flaky test is one that passes and fails on the same code; rate = runs whose result differs from the previous run divided by total runs). Decision: which tests to quarantine (temporarily stop them from blocking the build while they keep running) or repair.
- Time from first red build to first fix. Decision: is triage keeping up?
Metrics I deliberately left off
- Total test count and code coverage percentage (they go up whether or not quality does).
- Overall pass rate across every branch (draft branches drown the trunk signal).
- Per-person failure counts (it turns a data tool into a blame tool and invites people to game it).
Technical decision
I added a signature column to the results table (one row per test per run) and a second table linking a signature to its ticket. The dashboard's top panel was a simple query grouping failed rows by signature, with a count of distinct tests and builds. That schema choice, not the chart styling, is what made the rest possible. Here is that query run on a tiny sample (7 result rows, builds 41 and 42, the ticket table linking a signature to its ticket):
import sqlite3
db = sqlite3.connect(":memory:")
db.executescript("""
CREATE TABLE results (test TEXT, status TEXT, signature TEXT, build INTEGER);
CREATE TABLE signature_ticket (signature TEXT PRIMARY KEY, ticket TEXT);
""")
db.executemany("INSERT INTO results VALUES (?,?,?,?)", [
("test_login", "fail", "expired-credential", 41),
("test_profile", "fail", "expired-credential", 41),
("test_export", "fail", "expired-credential", 41),
("test_login", "fail", "expired-credential", 42),
("test_search", "fail", "timeout-search-db", 42),
("test_cart_tax", "fail", "assert-rounding", 42),
("test_billing", "pass", None, 42),
])
db.execute("INSERT INTO signature_ticket VALUES ('expired-credential', 'QA-311')")
query = """
SELECT r.signature,
COUNT(*) AS failed_results,
COUNT(DISTINCT r.test) AS distinct_tests,
COUNT(DISTINCT r.build) AS builds,
COALESCE(t.ticket, 'none yet') AS ticket
FROM results r
LEFT JOIN signature_ticket t ON t.signature = r.signature
WHERE r.status = 'fail'
GROUP BY r.signature
ORDER BY failed_results DESC, r.signature
"""
for row in db.execute(query):
print(row)
('expired-credential', 4, 3, 2, 'QA-311')
('assert-rounding', 1, 1, 1, 'none yet')
('timeout-search-db', 1, 1, 1, 'none yet')
Six failed rows became three lines: GROUP BY signature collapses rows with the same signature, and the counts show how big each cause is. The same query over the real 240 failed rows is what produced the 9 signatures below.
Result (derived from the example data, not a benchmark)
On the first night we ran it, 240 failing results collapsed into 9 signatures, and the top signature (one expired test credential) explained 150 of them, so 240 items to read became 9. Beyond that, the 15-minute weekly review shifted from arguing about which tests to blame to assigning owners to signatures.
Trade-offs and pitfalls
- Over-grouping can hide a second, unrelated bug behind a large signature, so I kept a drill-down to individual tests.
- A metric nobody acts on is decoration. I kept a metric only if I could name the decision it feeds.
- Be ready to say what you would do differently (for example, I would have interviewed the consumers before choosing metrics, not after).
The nightly pass rate fell from 98 to 92 percent after a batch of UI tests was added. How do you investigate, what evidence separates real product failures from unreliable tests or environment problems, and how do you keep confidence in the pipeline meanwhile?
Sample Answer
Direct answer
Do not assume the product got worse or that the new tests are bad. First split the drop into the old tests and the new ones, then classify every failure as a real regression, a flaky test, an environment problem or a test-data problem, using reruns and clustering as evidence. Meanwhile keep the original suite as the gate and run the new UI batch as non-blocking, so the pipeline stays trusted.
Structured elaboration
How I investigate
- Freeze the facts: which commit, which run, which runner. Rerun the same commit to see what is stable. A runner is the machine that executes the CI (continuous integration, the automated build-and-test pipeline) jobs.
- Split failures by cohort: old suite versus new UI batch, and by first-failure time.
- Rerun failures in isolation and on a clean runner: deterministic or intermittent?
- Cluster by error signature, runner and time window. An error signature is the first line of the failure message with volatile bits (ids, timestamps) removed, so identical causes group together.
- Bisect (search commits for the first bad one) if the old tests dropped.
Evidence that separates the causes
| Cause | Evidence | First action |
|---|---|---|
| New regression in the product | Fails on every rerun with the same assertion on every runner; reproduces by hand or through the API; tracks to a recent commit | File a defect, block if in a critical path |
| Unreliable (flaky: passes and fails on the same code) test | Passes on rerun with no change; varying messages (timeouts, element not found, stale element meaning the page redrew after the test grabbed a button); order-dependent; failure rate steady regardless of commits | Quarantine (park the test outside the gating run so it cannot block merges, but keep it running and visible) with an owner and expiry, then fix the test |
| Environment problem | Failures cluster on one runner, time window or dependency; one message such as connection refused or 503; disappear on another runner | Fix or replace the environment, then rerun |
| Test data problem | Shared data changed by parallel tests; results depend on order or time of day; cleared by a data reset | Isolate data per test |
Keeping confidence in the pipeline meanwhile
- Keep the original suite as the gate; its 98 percent baseline is unchanged and still means something.
- Run the new UI batch as non-blocking with a named owner and an expiry date (say two weeks), and publish both pass rates separately every day.
- Track first-attempt pass rate; silent auto-retries hide flakiness and should never be the reported number.
- Admit a new test to the gate only after a run of consecutive green nights (the length is a team convention, for example 20).
Worked example
A quick sum shows why the split matters. Say there were 500 tests with 490 passing (98 percent), and after adding 100 UI tests there are 600 with 552 passing (92 percent).
- If the old tests are unchanged (490 still pass), the new tests passed 552 - 490 = 62 of 100, a 62 percent pass rate. That points at the new tests or their environment.
- If instead all 100 new tests passed, the old ones would be at 552 - 100 = 452 of 500, which is 90.4 percent: a real regression in the old suite.
The same headline number implies opposite investigations, so the cohort split comes first.
Classifying real failures (illustrative)
| Failure message | What a rerun showed | Bucket |
|---|---|---|
Expected total 42.00 but was 40.00 | Same failure on 3 reruns, on 2 runners | Real regression |
Timeout waiting for #pay-button | Passed on rerun, different runner each time | Flaky test |
stale element reference | Passed on rerun, no code change | Flaky test |
connection refused: payments-stub:8080 | 14 failures, all on runner-3, gone on runner-1 | Environment |
duplicate key: user test@example.com | Fails only when two tests run in parallel | Test data |
Non-blocking simply means the batch still runs and reports, but a red result does not stop a merge or release.
Trade-offs and pitfalls
- Blaming the tests reflexively: some failures are real, so triage each one.
- Deleting failing tests, or quarantining with no expiry, turns the quarantine into a graveyard.
- Rerunning until green creates false confidence.
- What would change my call: if the old suite has dropped too, this is no longer a new-test problem, and I would escalate it as a product or environment issue and block the release.
Across three releases, defect density fell steadily while customer-reported incidents rose sharply. How would you investigate the contradiction, and what might each explanation change about how you measure quality?
Sample Answer
Direct answer
Two things can both be true, so the first job is to find out which measurement is misleading. Defect density is defects per unit of code (usually per thousand lines, KLOC), so it falls whenever the code grows faster than the defect count. Customer-reported incidents measure what customers felt. I would investigate whether the numerator, the denominator, or the detection process changed, and classify the incidents by root cause before touching the testing strategy.
Worked example (illustrative numbers)
| Release | Defects | Code (KLOC) | Density | Incidents | Customers | Incidents per 1,000 customers |
|---|---|---|---|---|---|---|
| 1 | 50 | 100 | 0.50 | 10 | 4,000 | 2.5 |
| 2 | 55 | 130 | 0.42 | 18 | 5,000 | 3.6 |
| 3 | 60 | 200 | 0.30 | 30 | 6,000 | 5.0 |
Density fell 40% (0.50 to 0.30) while defects went up (50 to 60) because the code doubled. Incidents tripled and, even per customer, doubled (2.5 to 5.0). The dashboard said "better", customers said "worse", and no one is lying.
Terms used below, in plain words
- Root cause: the underlying reason an incident happened (for example a bad configuration value), as opposed to the symptom customers saw.
- Postmortem: the written review after an incident describing what happened and why.
- Happy path: the normal, everything-goes-right route through a feature; tests that only cover it miss odd inputs and failures.
- Environment parity: how closely the test environment matches production (same data shape, configuration, versions, scale).
- Telemetry gap: something goes wrong in production but no log, error report or metric records it.
- Error tracking: a tool that collects production exceptions automatically.
- Test-to-incident traceability: being able to link each incident to the test that should have caught it (or to the fact that none exists).
- Version-control churn: how much code was changed in a period, taken from commit history.
Which I would check first: the denominator and the incident classification, because both use data already in hand and take an hour or two. Detection and telemetry come next (they need comparing sources), and coverage blind spots and definition drift last (they need sampling and manual review). Rank by what the evidence shows, not by which theory is most appealing.
Hypotheses, the evidence to check, and what each would change in how I measure
| Hypothesis | How to check | What it changes |
|---|---|---|
| Denominator growth hides absolute defects | Plot raw counts and density on changed code only | Measure density on changed code, plus incidents per user |
| Incidents are not code defects (configuration, infrastructure, data, third-party) | Classify every incident by root cause from postmortems and tickets | Track incident rate by cause, not just by defect |
| Detection got worse: fewer bugs found internally | Compare share found before release versus in production per release | Track escape rate at fixed age |
| Coverage blind spots: tests run in an environment unlike production, happy paths only | Map each incident to the test that should have caught it; check test data and environment differences | Track test-to-incident traceability and environment parity |
| Telemetry gap: customers hit issues we cannot see, or support intake improved so more gets reported | Compare incident reports against error tracking and logs; check intake changes | Add production monitoring as a detection source |
| Severity or definition drift | Re-rate a sample of old defects by today's rubric | Freeze definitions, log any change |
High automation rate yet production defects rising: automation percentage says how many test cases run by machine, not how much behaviour they verify. Check whether automated tests assert meaningful outcomes, cover integrations, configuration and unusual data, run against realistic environments, and whether failing tests are ignored as noise.
Data sources: incident tickets and postmortems, support tickets, production error tracking, release and deploy history, test management and continuous integration (CI, the automated build-and-test system) results, version-control churn, customer counts.
Corrective actions (chosen from the findings): add tests where incidents actually clustered, make defect and incident classification mandatory, add production checks for the classes of failure tests cannot reach, and change the headline metric to something customers would agree with.
Pitfalls
- Fixing testing before finding whether the incidents were code defects at all.
- Trusting one metric because it is easy to compute.
- Explaining the gap with a single theory. Several can apply at once, so rank by evidence.
Which metrics tell you whether an automated suite is healthy? How would you measure each one, what trend would worry you, and what would you do about it?
Sample Answer
Direct answer
A healthy suite is one the team trusts, that gives fast feedback, that catches real defects, and that costs a sustainable amount to maintain. No single number shows all four, so I track a small set of metrics, one group per question, and for each I know how it is measured, which trend worries me, and the one action it triggers. (CI means continuous integration, the automated system that builds and tests every change. A flaky test is one that passes and fails on the same code. Quarantine means moving an unreliable test out of the gate that blocks merges. p95 is the value 95% of observations fall below, so it describes the slow tail rather than the average, and p50 is the median. Test rot is a suite decaying as the product changes and tests stop matching it. Escaped defects are bugs found after release. Wall-clock time is elapsed real time, not CPU time. To shard and parallelise is to split the suite into pieces that run at once on several machines. A runner is the machine that executes CI jobs. A triage rota is a rotating on-call duty to look at red builds. Hard-coded waits are fixed sleeps, such as waiting 5 seconds for a page, instead of waiting for a condition. If you are starting from nothing, begin with pass rate, flake rate and duration; the cost and deflection rows are organisation-level extras.)
The metrics, grouped by the question they answer
Reading the table by question: can I trust the suite (pass rate, flake rate, quarantine size and age); is it fast (duration and queue time, time to green); does it find bugs (defect escape rate); is it affordable (maintenance cost per test, manual-test deflection).
| Metric | How I measure it | Trend that worries me | What I do |
|---|---|---|---|
| Pass rate on the main branch | passed / (passed + failed) per day, executed tests only, with skipped and quarantined counts shown beside it | Sliding for weeks, or a flat 100% while production bugs rise | Split real regressions from test rot before reacting |
| Flake rate | Share of executions on unchanged code that flip result on retry (this row only measures the rate; diagnosing why an individual test flakes is a separate investigation) | Rising, or the same tests flipping week after week | Quarantine with an owner and an expiry date, then fix or delete |
| Duration and queue time | p50 and p95 wall-clock of the full CI run, plus time waiting for a runner | p95 growing faster than test count, or people merging without waiting | Shard and parallelise, delete redundant tests, move slow ones to nightly |
| Time to green | Median time from first red build on main to the next green one | Growing, or red builds with no owner | Route failures to owners, run a triage rota |
| Defect escape rate | Escaped defects / (escaped + caught before release), per release | Flat or rising while pass rate looks good | Attribute each escape to the stage that should have caught it, add a test there |
| Quarantine size and age | Count of quarantined tests and the age of the oldest | Count only grows, entries older than the policy limit | Enforce expiry: fix or delete |
| Maintenance cost per test | Engineer hours spent fixing or updating tests per month / number of tests | Cost per test rising | Remove low-value tests, fix brittle patterns (for example, hard-coded waits) |
| Manual-test deflection | Automated cases / (automated + manual regression cases), and hours of manual regression per release | Flat while release effort stays high | Automate the manual checks repeated most often |
Targets, cadence and the organisation view
- I set targets against each team's own baseline first (for example, "no quarantined test older than a fixed number of days"), not a universal number borrowed from another company.
- The team reviews a one-page view weekly; an engineering manager reviews the trends monthly with the same definitions rolled up across teams. The organisation dashboard adds maintenance cost per test and manual-test deflection, because those are the numbers that show whether automation is paying for itself.
Worked example
A team has 1,200 tests. A quarter ago it spent 42 engineer-hours a month on test upkeep. Now it spends 60.
- Then: 42 h x 60 min / 1,200 tests = 2.1 minutes per test per month.
- Now: 60 h x 60 min / 1,200 tests = 3.0 minutes per test per month, about 43% more (60 / 42 = 1.43).
- Meanwhile pass rate stayed at 98% and quarantine grew from 10 to 45 tests. The pass rate alone says "fine"; the cost and quarantine metrics say the suite is quietly decaying. The action is to review the 45 quarantined tests, delete or fix them by their expiry date, and look at which tests take the most upkeep.
Defect escape rate traced: a release had 15 defects, 12 caught before release and 3 escaped, so 3 / (3 + 12) = 20%. If pass rate stayed 98% while that rate went from 20% to 30% over two releases, the suite is passing yet missing more.
Trade-offs and pitfalls
- Any single metric can be gamed (skipping tests lifts pass rate, deleting tests lifts everything), so I pair each with a counter-metric, a second number that exposes the cheat: pass rate with skipped and quarantined counts, duration with escape rate (a suite made fast by deleting tests will show escapes rising).
- Too many metrics means none is acted on. Each one must map to a decision; if it never changes a decision I drop it.
- Raw line coverage is deliberately absent: it says code was executed, not that behaviour was checked. I prefer coverage of critical user paths.
Define pass rate for automated tests precisely, including how skipped and quarantined tests are handled. When can a high pass rate mislead stakeholders?
Sample Answer
Direct answer
Pass rate is the share of tests that gave a verdict and passed, over a stated scope and time window. A skipped test (not run, for example because of a marker or a missing prerequisite) and a quarantined test (known unreliable, moved out of the gate that blocks merges) gave no verdict about the current code, so I leave them out of the denominator. I report their counts right beside the rate so the exclusion is visible, not hidden.
Definition
pass rate=passed+failedpassed
Intuition: of the tests that actually judged the code, how many approved it. A test that crashed during setup counts as failed, since it did not confirm anything worked.
Worked example
A run has 1,000 tests: 900 passed, 30 failed, 50 skipped, 20 quarantined.
- My definition: 900 / (900 + 30) = 900 / 930 = 96.77%.
- Skipped and quarantined in the denominator: 900 / 1,000 = 90.0%. This punishes the suite for tests that gave no verdict.
- Skipped and quarantined counted as passes: 970 / 1,000 = 97.0%. This rewards not running tests.
- Reported next to it: executed share = 930 / 1,000 = 93.0%, plus "50 skipped, 20 quarantined".
When a high pass rate misleads
- A shrinking denominator. If the 30 failing tests get skipped instead, pass rate becomes 900 / 900 = 100.0% while 80 tests no longer run. Watch skipped and quarantined counts, not just the rate.
- Retries. A test that fails, then passes on retry, counts as a pass in a naive rate. That hides flakiness, so I also report first-attempt pass rate.
- Pooling versus averaging. Suite A has 10 tests at 100% and suite B has 1,000 tests at 90%. Averaging the two rates gives 95%, but pooled it is (10 + 900) / 1,010 = 90.1%. State which one you report.
- Weak or missing checks. A suite can pass 100% because its assertions are shallow or it never exercises risky paths. So a high pass rate is good only alongside evidence that tests can fail: escaped defects and coverage of critical behaviour.
Pitfall
Do not set a pass-rate target without also constraining skips and quarantine; otherwise the cheapest way to hit the target is to stop running the failing tests.
Unlock Full Question Bank
Get access to all Quality Metrics and Test Reporting interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.