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.
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.
How would you compute mean time to detect for regressions caught by automated tests? Define the start and end events precisely and explain what makes the number misleading.
Sample Answer
Direct answer
Mean time to detect (MTTD) for regressions is the average, over a set of regressions, of the time between when the bug was introduced and when an automated test first reliably reported it. A regression is something that used to work and broke after a code change.
Precise events:
- Start = the time the first bad commit was merged (found by bisecting, meaning searching commit history in halves for the first commit where the test fails). Not "when someone noticed", and not the time the build ran.
- End = the time of the first confirmed failing automated run for that regression: it failed and failed again on rerun, so a one-off flaky failure does not count.
TTD(regression) = first_confirmed_failure_time - first_bad_commit_merge_time
MTTD = average of TTD over the chosen set of regressions
The formula reads as: each regression contributes its own delay, and MTTD is just their average.
Compute it (per test and overall), then look at the shape
import sqlite3
db = sqlite3.connect(":memory:")
db.execute("""CREATE TABLE regressions (
regression_id INTEGER PRIMARY KEY,
test_id TEXT,
introduced_at TEXT, -- merge time of the first bad commit (found by bisect)
first_detected_at TEXT -- first CONFIRMED failing run (failed, and failed again on rerun)
)""")
rows = [
(1, "checkout", "2026-03-02 09:00", "2026-03-02 09:40"),
(2, "checkout", "2026-03-03 14:00", "2026-03-03 14:35"),
(3, "search", "2026-03-04 10:00", "2026-03-05 02:00"), # only the nightly suite covers it
(4, "search", "2026-03-05 11:00", "2026-03-06 02:00"),
(5, "search", "2026-03-06 16:00", "2026-03-07 02:00"),
(6, "login", "2026-03-07 08:00", "2026-03-07 08:25"),
(7, "login", "2026-03-08 13:00", "2026-03-08 13:30"),
(8, "billing", "2026-03-09 09:00", "2026-03-09 09:50"),
(9, "billing", "2026-03-01 12:00", "2026-03-15 02:00"), # slipped past for two weeks
]
db.executemany("INSERT INTO regressions VALUES (?,?,?,?)", rows)
db.execute("""CREATE VIEW ttd AS
SELECT regression_id, test_id,
ROUND((julianday(first_detected_at) - julianday(introduced_at)) * 24, 2) AS ttd_hours
FROM regressions""")
print("per test:")
for r in db.execute("SELECT test_id, COUNT(*), ROUND(AVG(ttd_hours),2) FROM ttd GROUP BY test_id ORDER BY test_id"):
print(*r)
print("overall mean hours:", db.execute("SELECT ROUND(AVG(ttd_hours),2) FROM ttd").fetchone()[0])
# Nearest-rank percentile: the value at position ceil(p * n) in sorted order.
def percentile(p):
return db.execute("""
SELECT ttd_hours FROM (
SELECT ttd_hours, ROW_NUMBER() OVER (ORDER BY ttd_hours) AS rn, COUNT(*) OVER () AS n FROM ttd)
WHERE rn = CAST((? * n + 0.999999) AS INTEGER)""", (p,)).fetchone()[0]
print("median hours:", percentile(0.5))
print("p90 hours:", percentile(0.9))
Output:
per test:
billing 2 163.41
checkout 2 0.63
login 2 0.46
search 3 13.67
overall mean hours: 41.11
median hours: 0.83
p90 hours: 326.0
Two details of the code. julianday() returns a date as a number of days, so subtracting two of them gives a difference in days, and multiplying by 24 turns it into hours (0.0278 days x 24 = 0.67 hours, the 40 minutes of regression 1). The percentile query picks the value at position ceil(p x n) in sorted order; SQLite has no ceiling function, so adding 0.999999 and casting to an integer (which truncates) does the same job. For p90 with n = 9: 0.9 x 9 = 8.1, plus 0.999999 is 9.099999, which truncates to 9, so it picks the 9th (largest) value. For the median: 0.5 x 9 = 4.5, plus 0.999999 is 5.499999, so the 5th value.
Hand check: regression 1 was merged 09:00 and first confirmed at 09:40, so 40 minutes = 0.67 hours. The nine values sorted are 0.42, 0.5, 0.58, 0.67, 0.83, 10, 15, 16 and 326 hours. They sum to about 370, so the mean is 370 / 9 = 41.1 hours. The median is the 5th value, 0.83 hours. Without the single 326-hour case the mean would be 44 / 8 = 5.5 hours. One number told three different stories.
What makes the number misleading
- Mean versus percentile on skewed data: detection times pile up near zero with a long tail, so the mean is dragged by a few slow cases. Report the median (typical) and a high percentile such as p90 (90 percent of regressions were caught within this time) together. With only 9 points the nearest-rank p90 is simply the maximum, so it needs a larger sample to mean anything.
- Batched runs: the
searchregressions above took 10 to 16 hours only because that suite runs nightly at 02:00. The number measures the schedule, not test quality. Break MTTD down by suite tier (per-commit, hourly, nightly). - Flaky tests: counting the first raw failure makes detection look faster than it is (a flake "detects" a bug that is not there yet) or hides a real failure among noise. Require confirmation as in the query above.
- Survivorship (only the cases that "survived" to be measured get counted, so failures are invisible): regressions that no test caught (found by customers) never get an
endevent, so they vanish from the average. A team that catches only easy bugs quickly gets a great MTTD. Always publish alongside a detection rate (regressions caught by tests divided by all regressions). An escape is a regression that got past the tests and reached customers, so tracking escapes shows what the average leaves out. - Uncertain start: bisect can be wrong when several commits interact, so treat start times as estimates and audit a sample.
- How an SRE or team would use it: set targets per suite tier on the median and p90, not the mean, for example "median under 1 hour and p90 under 24 hours for the per-commit tier" (illustrative targets to calibrate against your own history), and alarm when the p90 drifts past its target for several weeks running. A nightly-only tier can never meet a 1-hour target, which is a signal to add faster checks, not to blame the tests.
- Gaming: running more frequent trivial tests lowers MTTD without protecting anything. Guard by tracking detection rate and escapes (regressions that reached customers), and by weighting by severity.
Tell me about a time quality data changed a product or release decision. What did you measure, how did you present it, and what happened?
Sample Answer
Direct answer
Yes. I once recommended delaying a checkout redesign because our own data showed a customer-facing problem that a mostly green test report hid, and the product manager agreed to move the date by three business days. The story below is an illustrative skeleton: use your own real numbers, but keep the shape of what was measured, how the evidence was framed as a decision, and what changed afterwards.
Structured elaboration
A strong answer to this question has five parts, in this order:
- Situation and stakes (what was about to ship, and to whom).
- The specific measures you chose and why they, rather than the headline pass rate, spoke to customer harm.
- A comparison that makes the evidence hard to dismiss (a control group, a rerun, a trend).
- How you framed the decision: recommendation first, options with costs, an owner and a date.
- The result and what stuck, including what would have changed your mind.
The interviewer is listening for delivered quality results (which metric, which comparison, which decision), not for a generic "I built consensus" story.
Worked example
Situation. A checkout redesign was due on a Thursday. The regression suite (the automated tests that re-check old behaviour after each change; a failure there is a regression) was mostly green, and a canary (a release to a small share of real users first, here 5 percent of traffic) had run for a day.
Task. As the quality assurance (QA) lead I owned the quality call in the go/no-go meeting (the meeting where the team decides to ship or hold).
Action: measure. Two failing tests were in the payment path and had been labelled "known flaky" (a flaky test passes and fails on the same code with no change, so teams tend to dismiss its failures) without anyone checking. I reran both ten times on the same commit and they failed every time with the same message, the signature of a deterministic bug (one that happens every time the same steps are run) rather than flakiness. I also compared the canary's checkout error rate with a control group (users still on the old build, used as the yardstick for normal). In this illustrative case it was 1.8 percent against 0.6 percent, a 3x gap (1.8 / 0.6). At an assumed 20,000 checkouts a day, the 1.2-point gap would mean about 240 extra failed checkouts every day at full traffic (20,000 x 0.012).
Action: present. One page, decision first: "Recommend delaying three business days: payment failures are reproducible and canary users hit errors at 3x the control rate." One chart of canary versus control. The page read roughly like this (illustrative):
DECISION: Delay checkout redesign by 3 business days (owner: QA lead, decide by Wed 5pm)
WHY: 2 payment tests fail 10/10 reruns, same error (not flaky).
Canary checkout errors 1.8% vs 0.6% control (3x). Est. ~240 extra failed checkouts/day at full traffic.
OPTIONS: A ship as planned cost: ~240 failed checkouts/day, hotfix pressure
B ship, flag off cost: no launch value, 1 day work
C delay 3 days cost: marketing date moves
CHART: two lines, daily checkout error rate, canary vs control
Three options with costs: ship as planned; ship with the new checkout behind a feature flag (a switch that turns the feature on or off without a new deploy) that stays off; or delay three days. I recommended the delay and offered the flag as the fallback if the date was immovable, so the product manager had a choice instead of a veto.
Result. The team found a race (two operations that sometimes finish in the wrong order and corrupt the outcome) in refreshing the payment token, fixed it and added a regression test that failed before the fix and passed after. The canary error rate returned to the control group's level, the launch slipped three days and no customer saw the failure. We wrote the go/no-go criteria into the release checklist (no unexplained failures in the payment path; canary error rate within an agreed distance of control), so the next call needed less argument.
Trade-offs and pitfalls
- Bring evidence, not alarm. The delay was accepted because it rested on a reproducible test and a comparison group.
- Offer costed options. A bare "no" makes QA the blocker; a choice makes QA the adviser.
- Own the cost out loud. The delay cost a marketing date, and saying so built trust.
- Say what would have changed your call: if ten reruns had passed and the canary gap had been inside normal noise, I would have recommended shipping.
- Avoid the generic version: name the measure, the comparison and the decision.
Given a CSV of defect or incident records with creation, detection and resolution timestamps, write code that computes time to detect and time to restore. How do you treat missing timestamps, overlapping records and mixed time zones?
Sample Answer
Direct answer
Normalise every timestamp to UTC (Coordinated Universal Time) first, then take differences. Define the two metrics explicitly: time to detect is detected_at - created_at (how long a defect or incident existed before someone noticed) and time to restore is resolved_at - detected_at (from noticing to fixed). I use detection as the start of restore time because that is the team's response window; measuring from created_at instead gives total time in production, and I would say which one I picked. Missing values are excluded from the metric that needs them (and counted, never treated as zero), duplicate rows are removed, and overlapping incidents on one service are merged when reporting total downtime.
Terms. ISO 8601 is the standard text format for date-times, such as 2025-03-01T10:00:00+05:30. A UTC offset like +05:30 says how far local clock time is ahead of UTC. A naive timestamp has no offset, so you cannot know which zone it was written in. A CTE (WITH ... AS) in SQL is a named temporary result that the next query can read from.
Approach
- Parse ISO 8601 timestamps (the standard
2025-03-01T10:00:00+05:30format that carries its offset) and convert to UTC. - Drop exact duplicate ids (re-exports of the same record).
- Compute both durations per record, skipping records missing a needed timestamp or with a negative duration, and report how many were skipped. In the code below, missing timestamps and negative restore times are listed; a negative time to detect is silently left out of that metric (none occur in the sample), so a production version should list those ids too.
- For distinct downtime, sort by start per service and merge overlapping windows.
Code (Python standard library, runs as is)
import csv, io, statistics
from datetime import datetime, timezone, timedelta
CSV_TEXT = """id,service,created_at,detected_at,resolved_at
1,api,2025-03-01T10:00:00+00:00,2025-03-01T10:12:00+00:00,2025-03-01T11:00:00+00:00
2,api,2025-03-02T09:00:00-05:00,2025-03-02T09:30:00-05:00,2025-03-02T11:00:00-05:00
3,web,2025-03-03T08:00:00+00:00,,2025-03-03T09:00:00+00:00
4,api,2025-03-01T10:30:00+00:00,2025-03-01T10:40:00+00:00,2025-03-01T11:30:00+00:00
1,api,2025-03-01T10:00:00+00:00,2025-03-01T10:12:00+00:00,2025-03-01T11:00:00+00:00
5,web,2025-03-04T15:00:00+05:30,2025-03-04T15:20:00+05:30,2025-03-04T16:20:00+05:30
6,db,2025-03-05T12:00:00,2025-03-05T12:10:00,2025-03-05T12:50:00
7,db,2025-03-06T12:00:00+00:00,2025-03-06T12:30:00+00:00,2025-03-06T12:10:00+00:00
"""
def parse(ts, naive_flags, row_id):
if not ts:
return None
dt = datetime.fromisoformat(ts)
if dt.tzinfo is None: # no offset given: assume UTC and record that we guessed
naive_flags.add(row_id)
dt = dt.replace(tzinfo=timezone.utc)
return dt.astimezone(timezone.utc)
def load(text):
seen, rows, notes = set(), [], {"duplicates": 0, "naive_assumed_utc": set(), "bad_order": []}
for r in csv.DictReader(io.StringIO(text)):
if r["id"] in seen: # exact re-export of the same record
notes["duplicates"] += 1
continue
seen.add(r["id"])
c, d, s = (parse(r[k], notes["naive_assumed_utc"], r["id"]) for k in ("created_at", "detected_at", "resolved_at"))
rows.append({"id": r["id"], "service": r["service"], "created": c, "detected": d, "resolved": s})
return rows, notes
def minutes(a, b):
return None if a is None or b is None else (b - a).total_seconds() / 60
def metrics(rows, notes):
ttd, ttr, skipped = [], [], []
for r in rows:
d1, d2 = minutes(r["created"], r["detected"]), minutes(r["detected"], r["resolved"])
if d1 is None or d2 is None:
skipped.append(r["id"])
if d1 is not None and d1 >= 0: ttd.append(d1)
if d2 is not None and d2 < 0: notes["bad_order"].append(r["id"])
elif d2 is not None: ttr.append(d2)
return ttd, ttr, skipped
def union_downtime(rows):
"""Minutes of distinct impact per service, merging overlapping created..resolved windows."""
total = {}
by_service = {}
for r in rows:
if r["created"] and r["resolved"] and r["resolved"] >= r["created"]:
by_service.setdefault(r["service"], []).append((r["created"], r["resolved"]))
for svc, spans in by_service.items():
spans.sort()
merged = [list(spans[0])]
for a, b in spans[1:]:
if a <= merged[-1][1]:
merged[-1][1] = max(merged[-1][1], b)
else:
merged.append([a, b])
total[svc] = sum((b - a).total_seconds() / 60 for a, b in merged)
return total
rows, notes = load(CSV_TEXT)
ttd, ttr, skipped = metrics(rows, notes)
print("records kept:", len(rows), "| duplicates dropped:", notes["duplicates"])
print("naive timestamps assumed UTC for ids:", sorted(notes["naive_assumed_utc"]))
print("resolved-before-detected ids excluded from TTR:", notes["bad_order"])
print("ids missing a timestamp (skipped for the metric they need):", skipped)
print("time to detect (min): n=%d mean=%.1f median=%.1f" % (len(ttd), statistics.mean(ttd), statistics.median(ttd)))
print("time to restore (min): n=%d mean=%.1f median=%.1f" % (len(ttr), statistics.mean(ttr), statistics.median(ttr)))
print("distinct downtime per service (min):", union_downtime(rows))
SQL alternative (SQLite), appended below the code above so it reuses the same data
import sqlite3
db = sqlite3.connect(":memory:")
db.execute("CREATE TABLE raw (id TEXT, service TEXT, created_at TEXT, detected_at TEXT, resolved_at TEXT)")
db.executemany("INSERT INTO raw VALUES (?,?,?,?,?)",
[tuple(r.values()) for r in csv.DictReader(io.StringIO(CSV_TEXT))])
# strftime('%s', ...) converts any ISO offset to UTC epoch seconds; NULL or '' stays NULL via NULLIF.
query = """
WITH dedup AS (SELECT DISTINCT * FROM raw),
t AS (
SELECT id,
strftime('%s', created_at) AS c,
strftime('%s', NULLIF(detected_at, '')) AS d,
strftime('%s', NULLIF(resolved_at, '')) AS r
FROM dedup)
SELECT COUNT(d - c) AS n_ttd,
ROUND(AVG(d - c) / 60.0, 1) AS mean_ttd_min,
COUNT(CASE WHEN r >= d THEN 1 END) AS n_ttr,
ROUND(AVG(CASE WHEN r >= d THEN r - d END) / 60.0, 1) AS mean_ttr_min
FROM t
"""
print(db.execute(query).fetchone())
Output
records kept: 7 | duplicates dropped: 1
naive timestamps assumed UTC for ids: ['6']
resolved-before-detected ids excluded from TTR: ['7']
ids missing a timestamp (skipped for the metric they need): ['3']
time to detect (min): n=6 mean=18.7 median=16.0
time to restore (min): n=5 mean=57.6 median=50.0
distinct downtime per service (min): {'api': 210.0, 'web': 140.0, 'db': 60.0}
(6, 18.7, 5, 57.6)
Checking the numbers by hand: detect times are 12, 30, 10, 20, 10 and 30 minutes (id 3 has no detection time), so the mean is 112 / 6 = 18.7 and the median is 16. Restore times are 48, 90, 50, 60 and 40 (id 3 is missing a time and id 7 resolved before it was detected, so both are excluded), so 288 / 5 = 57.6. The api incidents 1 and 4 overlap (10:00 to 11:00 and 10:30 to 11:30 UTC), so they merge into 90 minutes, plus 120 for record 2 (09:00 at offset -05:00 is 14:00 UTC): 210.
Why web is 140 and db is 60. Web has two incidents: id 3 (08:00 to 09:00 UTC, 60 minutes, it has no detection time but downtime uses created and resolved) and id 5 (15:00 to 16:20 at +05:30, which is 09:30 to 10:50 UTC, 80 minutes). They do not overlap, so 60 + 80 = 140. Db has id 6 on 5 March (12:00 to 12:50, 50 minutes, naive so assumed UTC) and id 7 on 6 March (12:00 to 12:10 UTC, 10 minutes). They are on different days, so they do not overlap and are not merged: 50 + 10 = 60. Note id 7 is excluded from restore time because it resolved before it was detected, but its created-to-resolved window still counts for downtime.
Reading the SQL. strftime('%s', x) converts a timestamp text into seconds since 1970 in UTC, so subtraction is plain arithmetic. NULLIF(detected_at, '') turns an empty string into NULL, which SQL ignores in averages. COUNT(d - c) counts only rows where the difference is not NULL, so it counts rows that have both timestamps (6 here). SELECT DISTINCT * in the first CTE removes exact duplicate rows. SQLite here is just a convenient in-memory database; the same idea works in any SQL engine, including columnar ones.
Handling the three named problems
| Problem | Treatment | Why |
|---|---|---|
| Missing timestamps | Exclude from that metric only; report the count | Filling with zero or "now" biases the mean, and dropping the whole row loses a valid other metric |
| Overlapping records | Remove exact duplicate ids; merge overlapping windows per service for total downtime; keep incident-level times for per-incident statistics | Otherwise the same outage is counted twice |
| Mixed time zones | Require offsets, convert to UTC; naive timestamps get an explicit assumption (UTC here) that is recorded and reported | Comparing 09:00 -05:00 with 10:00 +00:00 as plain clock times gives wrong differences |
Complexity: parsing and durations are O(n); merging is O(n log n) for the sort. Memory is O(n). The SQL version does one pass after deduplication.
Edge cases and pitfalls
- Negative durations (resolved before detected) are data errors, so exclude and list them for repair.
- Report the median next to the mean; one long outage dominates a mean.
- Daylight saving changes create 23 or 25 hour days if you store local time without an offset.
- Naive timestamps are a guess. Ask the source system what zone it writes, and fix it at the source.
- Naming: DORA (dora.dev) now calls its recovery metric failed deployment recovery time, the time to recover from a deployment that fails and needs immediate intervention, measured from the failed deployment rather than from a detection timestamp. Older material calls it MTTR or time to restore service. State which start point your CSV supports before comparing with published benchmarks.
What quality and test metrics would you track for a delivery team, and for each one, what does it actually tell you and where can it mislead?
Sample Answer
Direct answer
Track a small balanced set: a few metrics about defects reaching users, a few about how fast and trustworthy the test signal is, and a couple about delivery health. For every metric, write down two things next to it: the decision it informs and the way it lies. A metric you cannot attach a decision to is decoration.
The set, what each tells you, and where it misleads
| Metric | What it tells you | Where it misleads |
|---|---|---|
| Defect escape rate (share of a release's defects found only after release) | How much the test effort is missing before users see it | Falls when customers stop reporting, or when defects get downgraded or never logged. Says nothing about severity unless you split it |
| Test pass rate | Whether the current build is healthy | Rises when tests are deleted, skipped, quarantined (parked outside the blocking set so their failures no longer count), or retried until green (rerun automatically until they happen to pass). A 100% pass rate on a weak suite is comfort, not safety |
| Flaky test rate (tests that pass and fail on the same code) | How much you can trust a red build | Hidden if retries are automatic. High flakiness makes teams ignore real failures |
| Feedback time (push to result) and per-test execution time | How long a developer waits | Averages hide the slow tail (see the worked example) |
| Change failure rate (deployments that cause a failure needing a fix, divided by all deployments) and recovery time (two of the DORA delivery metrics from the DevOps Research and Assessment programme; dora.dev now calls the recovery one failed deployment recovery time, the time to recover from a deployment that fails and needs immediate intervention, which replaced the older MTTR, mean time to restore service, and it also lists a fifth metric, deployment rework rate) | Whether fast delivery is coming at the cost of stability | Small deployments can make the rate look better while impact per failure grows. Averages hide one long outage |
| Open defects by severity and age | Release risk and neglected problems | A low count can mean nobody is looking. Severity labels are subjective |
| Customer-side signals (crash-free sessions, meaning the share of app sessions that end without a crash; support tickets per active user) | Product health as users experience it, the balance to engineering-side numbers | Lags by days or weeks and is affected by usage changes |
Code coverage (the share of code lines that tests execute) is a related signal that is deliberately left out of the table because it measures only whether code was executed, not whether any assertion checked the result (a test with no assertions still raises coverage). Use it as "where we definitely have no tests", never as proof of quality.
Quick numbers for the other rows (illustrative)
- Escape rate: a release has 40 defects logged in total, 30 found before release and 10 found by customers afterwards. Escape rate = 10 / 40 = 25%.
- Pass rate and quarantine: 1,000 tests run, 50 fail, so 950 / 1,000 = 95%. If 30 of the failures are quarantined and excluded, the report shows 950 / 970 = 97.9%. The number rose although nothing was fixed, which is why quarantined counts must be shown beside it.
- Flaky test rate: 12 of 400 tests both passed and failed on the same code this week, so 12 / 400 = 3%.
- Change failure rate: 6 of 40 deployments this month needed a fix or rollback, so 6 / 40 = 15%.
- Crash-free sessions: 9,900 of 10,000 sessions ended without a crash, so 99%. Note that 99% still means 100 crashed sessions.
Worked example: throughput and execution time under parallelism
A suite has 1,200 tests averaging 2 seconds each, so 2,400 seconds of compute. Split across 4 parallel machines (shards) the ideal wall-clock time is 2,400 / 4 = 600 seconds. In practice the shards are uneven: if the slowest takes 900 seconds, the run takes 900 seconds, not 600. Add 5 minutes (300 seconds) waiting in the queue for a free runner and a developer waits 1,200 seconds, 20 minutes, even though "average test time" is still 2 seconds. Retries also distort: if 3% of tests (36) are retried, that adds 36 x 2 = 72 seconds of compute, invisible in the average but visible as extra cost and hidden flakiness. So report feedback time end to end and its 95th percentile (the value 95% of runs come in under), plus retry count, not only average per-test time or tests per hour.
Thresholds and balance
There are no honest universal numbers. Set thresholds against your own baseline and act on direction: escape rate rising two releases in a row, flake rate creeping up, feedback time past what developers will wait for (they start skipping it). Read product and engineering metrics together: fast feedback with rising escapes means the fast tests are the wrong tests; falling escapes with falling customer usage proves nothing.
Gaming and pitfalls
Every row above can be gamed (delete tests, downgrade severity, retry to green). Prefer trends over targets, publish denominators, and never rank individuals with these numbers.
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.