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.
What is a quality metric, and how do you tell a meaningful one from a vanity one? Give examples of each in a release-readiness setting and say how you would validate that a metric is worth tracking.
Sample Answer
Direct answer
A release-readiness setting is the moment a team decides whether a build is fit to ship, and the metrics that feed that decision. A quality metric is a measurement of the product, or of the process that builds it, that helps someone make a decision about quality. A meaningful one changes a decision and is hard to improve without genuinely improving quality. A vanity metric looks impressive, can only trend upward, and nobody would act differently if it moved.
How to tell them apart (four questions)
- Decision test: if this went red, what would we do, and who does it? No answer means vanity.
- Outcome link: does it connect to something users or the business feel (incidents, escapes, churn), or only to activity?
- Gaming test: could a team move it a lot without improving the product?
- Definition test: is the numerator, denominator and time window fixed, so two people compute the same value?
Release-readiness examples
| Vanity | Why | Meaningful | Why |
|---|---|---|---|
| Total number of tests | More tests can be worse tests | Open Sev1 and Sev2 defects at release cut (the moment the release candidate is frozen; severity levels: Sev1 is an outage or data loss, Sev2 a major feature broken) | Directly gates the go or no-go call (the meeting where someone decides ship or hold) |
| Overall pass rate | Barely moves, hides which tests matter | Pass rate of critical-path tests (the tests for flows users must complete, such as sign-in and checkout), with flaky ones (tests that sometimes pass and sometimes fail on the same code) counted separately | Tied to revenue and safety flows |
| Bugs found per tester | Rewards logging, not quality | Defect escape rate per release (defects found after release divided by all defects for that release) | Measures what got past you |
| Test cases executed | Activity, not coverage of risk | Failed deployment recovery time, the time to recover from a release that fails and needs immediate intervention (dora.dev's current name for the metric older material calls time to restore service or MTTR, mean time to restore) | Shows real resilience |
How to validate that a metric is worth tracking
Back-test it (compare the metric's past values with how those releases actually turned out) before adopting it. Illustrative data for four past releases:
| Release | Open Sev1/Sev2 at cut | Pass rate | Incidents after release |
|---|---|---|---|
| R1 | 6 | 97% | 4 |
| R2 | 1 | 98% | 0 |
| R3 | 4 | 99% | 3 |
| R4 | 0 | 98% | 1 |
Pass rate stays between 97% and 99% while incidents range from 0 to 4, so it does not discriminate (it fails to separate good releases from bad ones). Open severe defects orders the releases almost the same way as incidents (ranked worst to best by open severe defects: R1 with 6, R3 with 4, R2 with 1, R4 with 0; ranked by incidents: R1 with 4, R3 with 3, R4 with 1, R2 with 0. Only R2 and R4 swap places), so it is worth keeping. Four points is a sanity check, not statistics, so keep watching it. Then pilot it for two or three releases, confirm the definition is written down, check whether it moved for a real reason when it moved, and retire it if it never changes a decision.
Pitfalls
A metric can be meaningful for one team and vanity for another. Do not add a metric because it is easy to collect, and do not set a target until you know how it behaves.
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.
How do you measure whether your team's testing is actually effective rather than just busy? What would you track, what targets would you set, and what would make you distrust the numbers?
Sample Answer
Direct answer
Busy testing is measured by activity (tests run, cases written, tickets closed). Effective testing is measured by outcomes: are defects caught before customers see them, and is the signal fast and trustworthy enough that people act on it? I would track escapes, whether tests would actually notice a break, and the health of the pipeline, set targets as directions against my own baseline, and distrust any number that improves while customer experience does not.
What I would track (the core set is three items: escape rate, flaky rate and feedback time; the root-cause tag, mutation score, runtime signals and change failure rate are extras for teams that already have the basics)
- Defect escape rate, weighted by severity: defects found after release divided by all defects for the release, where each defect counts by its weight (for example Sev1 = 8, Sev2 = 4, Sev3 = 1; the weights are a team choice, illustrative here). The core outcome measure. Example: a release has 10 defects. Escaped: one Sev1 and one Sev3 (8 + 1 = 9 points). Caught before release: two Sev2 and six Sev3 (8 + 6 = 14 points). Weighted escape rate = 9 / (9 + 14) = 39%, while the unweighted rate is 2 / 10 = 20%. The weighted view shows that the one escape that mattered was serious.
- Escape root-cause tag: for each escaped defect, label whether a test existed and missed it, no test existed, or the environment could not reproduce it. This tells you what to fix.
- Mutation score (supplement to coverage): a mutation testing tool makes small deliberate changes to code (for example flipping a > into >=) and reruns the tests. If the tests still pass, that "mutant" survived, which means no test really checks that behaviour (an assertion is the line in a test that checks a result; survivors mean such lines are missing). Example: 200 mutants generated on the modules changed this month, 150 killed, so the score is 150 / 200 = 75%. The 50 survivors are a to-do list of missing assertions. Mutants that behave identically to the original code (equivalent mutants) inflate survivors, so review before chasing.
- Flaky test rate and feedback time (how long from push to result): a suite people do not trust or wait for is not effective.
- Runtime signals: production error rates and canary results (releasing to a small share of users first) show what tests missed, and feed the root-cause tag.
- Change failure rate: the share of deployments causing an incident or rollback, a delivery-level check. Example: 40 deployments, 3 needed a rollback, so 3 / 40 = 7.5%.
Coverage (the share of code lines that tests execute) is one input here, never the verdict.
Targets
Choose directional, baseline-relative targets you can defend: halve the flaky rate this quarter; no Sev1 escape (a top-severity defect such as an outage or data loss) in an area we claim is covered; mutation score on changed code trending up; feedback time under the budget developers agree they will wait for. Avoid a single global number such as "90% coverage".
What should make you distrust the numbers
- Pass rate or coverage rising while escapes stay flat (tests without assertions, deleted or quarantined tests).
- Escape rate falling while support tickets or incidents do not (defects unlogged, downgraded or reclassified).
- Mutation score high because only trivial mutants were generated.
- Everything improving right after a target is announced.
Improving reliability without slowing delivery
Run fast tests on every pull request (a proposed code change awaiting review) and slower suites after merge; run mutation testing only on changed files, nightly; quarantine flaky tests (move them out of the gate that blocks merges, still visible and running) with an owner and an expiry date rather than blanket retries. Pipeline health means the automated build-and-test system being fast and trusted, not just green.
What is defect density, how is it calculated, and why can defects per thousand lines of code mislead? What denominators would you consider instead?
Sample Answer
Direct answer
Defect density is the number of defects found in a piece of software divided by its size. The classic form is defects per KLOC (thousand lines of code). It is a comparison tool for spotting modules or releases that look unusually buggy, but lines of code is a poor ruler, so I would pair it with better denominators and never use it to compare across languages or teams.
Calculation with a small example
Density = defects / (lines of code / 1,000). Four modules:
modules = [
("checkout", 18, 12000),
("auth", 3, 1500),
("reporting", 5, 20000),
("generated_stub", 0, 0),
]
def density_per_kloc(defects, loc):
if loc <= 0:
return None # no size means no meaningful density
return defects / (loc / 1000)
for name, d, loc in modules:
dens = density_per_kloc(d, loc)
print(name, "n/a" if dens is None else round(dens, 2))
sized = [(d, loc) for _, d, loc in modules if loc > 0]
total_d = sum(d for d, _ in sized)
total_loc = sum(loc for _, loc in sized)
print("pooled:", round(density_per_kloc(total_d, total_loc), 2))
ratios = [density_per_kloc(d, loc) for d, loc in sized]
print("mean of ratios:", round(sum(ratios) / len(ratios), 2))
Output:
checkout 1.5
auth 2.0
reporting 0.25
generated_stub n/a
pooled: 0.78
mean of ratios: 1.25
- Zero size: return "not available" (None), not 0 and not a crash. A module with no lines has no density.
- Roll-ups: the overall figure is total defects over total size (26 / 33.5 KLOC, about 0.78), not the average of module densities (1.25), which over-weights small modules.
- Rounding: keep raw counts and round only for display.
Why per-KLOC can mislead
- Verbose languages and generated code inflate size and shrink density without any quality change; splitting one line into three also lowers it.
- Small modules swing wildly: auth has the highest density (2.0) on just 3 defects.
- Density reflects detection effort as much as quality: a heavily tested module finds more defects, and a zero-defect module may simply be untested.
- Units matter: defects per KLOC compares only within the same counting rules (are comments, blanks and generated code excluded?). Comparing across languages is the common misreading.
Better denominators
- Function points: a size measure based on features delivered (inputs, outputs, queries, data files), independent of language.
- Changed lines this release (code churn): normalises for how much was actually touched.
- Usage: defects or incidents per million requests or per active user, matching what customers experience.
- Effort or features shipped, as a rough cross-check.
Pair density with severity and pick one denominator per comparison, stated on the chart.
What guardrails would you put on a quality dashboard so teams cannot quietly game the numbers, and how do you keep the measurement useful while doing it?
Sample Answer
Direct answer
Assume any number that becomes a target will be gamed, since Goodhart's law says a measure stops being reliable once it is used as a target. My guardrails make gaming visible and unrewarding: pair each metric with a counter-metric, show denominators, collect data automatically, define metrics in reviewed code, and use the numbers to guide conversations rather than to rank people. Then I keep measurement useful by favouring trends over targets and retiring metrics that stop informing decisions.
Worked example: gaming a pass rate
A suite has 500 tests, 25 are failing. The team "fixes" the dashboard by quarantining those 25 (moving them out of the blocking set and out of the pass-rate count). The dashboard now says 475 of 475 passed, 100%. The honest figure is 475 / 500 = 95%, with 25 known problems hidden. A guardrail that shows the quarantined count next to the pass rate, and expires quarantines, defeats this.
Terms used below: coverage is the share of code lines that tests execute. A mutation score comes from a tool that makes tiny deliberate breakages (mutants, for example flipping > to >=) and reports the share of mutants that at least one test catches, so it measures whether tests actually check behaviour. A flaky test passes and fails on identical code. CI (continuous integration) is the automated system that builds and tests every change. A quarantine list holds tests that still run but no longer block builds.
Worked example: counter-metric pairing (illustrative numbers)
A team is told to raise coverage from 70% to 90%. They add tests that call code but assert nothing. Coverage reaches 92%, but of 50 mutants the tool creates, the tests catch only 20 both before and after: mutation score 20 / 50 = 40%, unchanged. Shown alone, coverage says "much better"; shown with the mutation score, it says "no real improvement". The same logic pairs speed with escape rate: if release cycle time drops from 10 days to 5 while customer-found defects per release (escapes) rise from 3 to 9, the pair shows speed was bought with quality.
Guardrails, why each works, what it costs
| Guardrail | Why it works | What it costs |
|---|---|---|
| Counter-metric pairing (pass rate with flaky and quarantined count; coverage with mutation score; speed with escape rate) | Improving one at the expense of the other shows up | More numbers to read, so keep the pairs few |
| Show counts and denominators, not only percentages | "95% of 500" resists cherry-picking (choosing only the flattering slice of data) | Busier dashboards |
| Automated collection from source systems (CI, defect tracker) | No self-reporting to massage | Integration work and data-quality upkeep |
| Metric definitions versioned in a repository (kept as files in version control, so every change is visible, dated and reviewed), changes reviewed | Nobody redefines "passed" quietly | Review overhead |
| Quarantine rules: owner, expiry date, visible count | Stops quarantine becoming a bin | Some friction for genuinely flaky tests |
| Sampled audits (check 10 closed defects or reclassifications a month) | Catches severity downgrades and "works as intended" closures | Someone's time |
| Do not use for individual performance reviews | Removes the main incentive to game | Managers must find other signals for individuals |
| Outcome cross-check (escape rate against support tickets and incidents) | Unlogged defects still show up somewhere | Requires access to other data |
Keeping the measurement useful
- Look at trends and anomalies, and ask "what happened?" instead of "who did this?".
- Involve the team in choosing metrics so they own them.
- Review quarterly and retire metrics that never change a decision.
- Do not over-guard: a dashboard so locked down that it stops being read is worse than a slightly gameable one.
Pitfalls
Guardrails only reduce gaming, they cannot stop a determined team. Culture matters more: if numbers are punished, people hide problems, and the best guardrail is being safe to report bad news.
Unlock Full Question Bank
Get access to all 6 Quality Metrics and Test Reporting interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.