Regression testing best practices that remove work

Regression testing best practices ranked by cost and payoff: rerun what a change can reach, retire checks nobody can explain, add one for every escape.

Four glass pins stand in a row on a base, one of them orange, with three more lying flat in front

Regression testing reruns existing checks after a change to confirm that what worked before still works. The best practices that pay take work out of the suite: rerun only the checks a change can reach, retire any check whose failure nobody could explain, and add a check for every regression that escapes.

A list of best practices makes the suite bigger

The usual list of regression testing best practices runs to ten items or more. Automate the suite, widen coverage, add visual checks, test more browsers, run everything on every commit. Each item is sound alone, each adds something to write, run or maintain, and nothing on the list says what to take away.

A suite grows without help. The ISTQB Foundation Level syllabus (v4.0.1) notes that “generally the number of regression test cases will increase with each iteration or release.” Writing a check is the small part of its cost. The larger part is paid on every run, in the wait for a result and in the attention each failure takes from whoever reads it.

Regression testing in software testing sets out the types of run and which changes call for each. This post takes a suite that already exists and asks which habits are worth their price. The ones that pay are decisions on what a change does not need rerun, which checks have stopped earning their place, and what evidence justifies a new one.

Five practices pay, and each one has a price

The table ranks five practices for a team that already runs a regression testing suite, by how much each changes the cost of a run and the trust placed in its result.

RankPracticeWhat it costsWhat it buys
1Rerun what the change can reachA code-to-check map kept current, and a full run kept on a scheduleA result while the change is fresh in its author’s mind
2Retire a check whose failure nobody could explainReview hours, and an owner to sign each removalFailures that get read
3Add a check for every escaped regressionOne reproduction per escape, from a report good enough to reproduceReach that follows where the product has failed
4Run the likeliest failures firstA failure history kept clean of false alarmsA shorter wait for the first failure
5Send a person where the scripts do not goA scoped session in each releaseRegressions no check was written for, caught before release

Ranks one and two take work out, and rank three is the one addition that comes with evidence of a gap. Rank four, test case prioritisation, changes the order of a run and nothing else. Rank five is exploratory testing pointed at what the release changed, and its findings feed rank three.

Automating more and raising coverage are missing on purpose, since both invest in the size of the suite, and risk-based testing decides upstream which areas deserve checks at all. Running everything on every commit stays sound while the whole suite finishes in a few minutes, and on a suite that short the list starts at rank two.

The advice every list repeats, and where it fits

The best-practice lists that rank for this search share most of their items. Each has a place in the five above, as a condition one of them needs or as a smaller version of one.

Common adviceWhere it fits
Automate the regression suiteAutomate a check once the behaviour it guards has settled. A check rewritten every sprint costs more as a script than as a manual check, and manual vs automated testing sets out the trade
Prioritise by risk and criticalityRisk decides which areas get checks at all, and rank four decides their order in a run
Run smoke tests firstThe first tier of the pipeline below, a few minutes of checks on the paths that must work
Keep test data restorable and the environment stableA condition for rank two. When data or the test environment drifts between runs, a failure cannot be told apart from noise, so test data management comes before any pruning
Run tests in parallelShortens the wait without removing anything, and pairs with rank one
Test end-to-end journeys and integrationsKeep a few journey checks on the paths that earn money, and push everything else down to the fastest level that asserts it, the fourth row of the retirement table below
Watch performance between releasesA slowdown is a regression too, and it needs a recorded baseline to compare against, so a timing budget is written and owned like any other check
Maintain the suiteRank two, given a question that ends each review with a decision
Integrate with the CI/CD pipelineThe tiers below, each with a different trigger and a different power to block

A change should rerun only the checks it can reach

The syllabus puts the instruction in one line: “It is advisable first to perform an impact analysis to recognize the extent of the regression testing.” Done for each change by a tool, that is test impact analysis. Paul Hammant’s 2017 article The Rise of Test Impact Analysis states the idea it rests on, that “not all tests exercise every production source file”, and describes a map built from code coverage or instrumentation recorded while the tests run.

Reach comes in three kinds, and a file map answers only the first, the checks that execute the changed files. A migration, a changed default or an environment setting reaches through data and configuration, where no file map links a change to a check. A stylesheet, a font or a shared component reaches every page that loads it, the ground visual regression testing works on.

One rule keeps selection safe. When the reach of a change is unknown, nothing is selected out and the whole suite runs, because the worst answer a selector can give is an empty list followed by a green build.

Selection deletes nothing. Every check still runs on a schedule and against the release candidate, away from the path that blocks a merge, and a failure there that selection missed is fixed as a defect in the map.

In a pipeline that gives four tiers, each with its own trigger.

TriggerWhat runsWhat a failure blocks
Every pushSmoke tests on the paths that must workThe rest of the run
Pull requestThe checks the change can reach, chosen by selectionThe merge
NightlyThe full suiteNothing directly. A failure opens a defect in the product or in the map
Release candidateThe full suite, plus a scoped exploratory session on what the release changedThe release, through the go/no-go decision

A check whose failure nobody could explain should be retired

Selection decides when a check runs. Retirement decides whether it should exist, and one question settles it. If this check failed tomorrow, which defect would it be reporting, and who would act on it? The check’s own history usually holds the answer.

What the history showsWhat to do with the check
It failed for a defect that was then fixedKeep it, because the ticket is its reason
It has never failed, and it guards a fixed bug or a costly pathKeep it
It has never failed, and nobody can say what it protectsRewrite it against the requirement, or retire it
It fails only together with a faster check of the same behaviourRetire the slower copy
It passes and fails on the same codeQuarantine it with a named owner, then repair or retire it
Its expected result is edited each time it failsRetire it, because it records the build and checks nothing

The fourth row is a question of level, which regression vs integration testing sets out. The fifth decides whether failures get read at all. In 2016 John Micco wrote on the Google Testing Blog that “about 84% of the transitions we observe from pass to fail involve a flaky test”, and added: “It is human nature to ignore alarms when there is a history of false signals coming from a system.” That figure is one company’s measurement of its own pipeline and no benchmark for another team. The mechanism travels, since people who keep reading false alarms learn to dismiss the real one. The same post warns that quarantining a flaky test “could easily mask a real race condition or some other bug in the code being tested”, which is why a quarantined check needs a named owner.

Two reasons are never enough for retirement. A slow run is answered by selection and by running in parallel, because the suite is the record of failures the team has already met. A long run of passes is no evidence either. The syllabus says that “repeating the same tests can have a beneficial outcome, e.g., in automated regression testing”, and a check written from a fixed bug can pass for years with its reason still on the ticket.

Every escaped regression is a check the suite was missing

A regression bug that reaches a user is an escaped defect, and it is the best evidence a team gets about where its suite does not reach. An escape has one of three causes. Where no check covered the behaviour, one is added. Where a check covered it and selection left it out, the map is repaired. Where a check failed and was waved through, its record of false alarms is the thing to fix.

The fix gets a retest, which the syllabus calls confirmation testing, and one way it lists to do that is “adding new tests to cover any changes that were needed to fix the defect.” Kept in the suite, that test is the new regression check. The fix is unfinished until a check fails on the broken build and passes on the fixed one.

Escapes also answer the principle the syllabus names “Tests wear out”, long called the pesticide paradox. Its remedy is that “new tests may need to be written”, and an escape says where.

Writing the check needs the conditions the failure happened under, and a regression reported by a user tends to arrive as one sentence. With the Notarus widget on the page, the widget captures the page the reporter is looking at, and console logs, network activity, page URL, viewport and browser travel with the report as captured evidence. A failed request or a thrown error in that record is something the new check can assert on. Capture settings, browser support and performance budgets decide what is available, so some reports carry less.

Three numbers show whether the practices are working

A suite run this way can be judged on three figures a team already has. They belong together, since any one of them alone can be improved by making the suite worse, a warning testing metrics makes at length.

  1. Escaped regressions per release, sorted by the three causes above. A falling count with most escapes in the “no check” column means selection and pruning are safe.
  2. Time from a push to the first failing check. Ranks one and four shorten it, and a rise points at a map that selects too much or an order that has gone stale.
  3. The share of failures closed as false alarms. Rank two and the flaky-test quarantine lower it, and while it stays high, real failures are being dismissed with the rest.

A suite kept this way has a shorter daily run and fewer checks nobody can account for, and each addition traces to a regression that got out.

Common questions

What are the best practices for regression testing?

The regression testing best practices that pay most are five: rerun the checks a change can reach, retire checks whose failure nobody could explain, add a check for every regression that escapes, run the likeliest failures first, and send a person through the areas the scripts do not cover in each release.

How do you decide which regression tests to run?

Regression tests are chosen by what the change can reach. A map from source files to the tests that execute them selects the subset for a code change, a change to data or configuration with unknown reach reruns everything, and the full suite still runs on a schedule and against the release candidate.

When should a regression test be removed from the suite?

A regression test should be retired when nobody can say which defect its failure would report: the behaviour it guarded is gone, a faster test asserts the same thing, or its expected result is edited every time it fails. A slow run is a reason to select tests per change and is never a reason to delete them.

How often should the full regression suite run?

The full regression suite should run on a schedule, such as nightly, and against every release candidate, while a selected subset gates each pull request. The scheduled run exists to catch what selection missed, so a failure found only there points to a gap in the map that selection reads from.

What should happen after a regression escapes to production?

An escaped regression gets a fix and a new regression check that fails on the broken build and passes on the fixed one. The team also asks whether a check was missing, was left out by selection, or failed and was dismissed, because each answer repairs a different part of the suite.

Do flaky tests belong in a regression suite?

Flaky tests, which pass and fail on the same code, weaken a regression suite because the people reading it learn to dismiss failures. Each one should be quarantined away from the checks that block a merge, given a named owner, and then repaired or retired, since a quarantined test can also hide a real defect.

What is automated regression testing?

Automated regression testing is the practice of rerunning existing checks by script after each change, usually from a CI pipeline, to confirm that behaviour which worked before still works. It suits checks that repeat on every run and guard behaviour that has stopped changing, while a person keeps the areas where the expected result is still moving.

Should regression tests be automated or run by hand?

A regression check is worth automating once the behaviour it guards has settled and the check will run many times. Behaviour still being redesigned is cheaper to check by hand until it settles, and a scoped exploratory session in each release covers what no script was written for.

Is regression testing the same as UAT?

Regression testing and UAT answer different questions. Regression testing reruns existing checks after a change to confirm nothing that worked has broken, while user acceptance testing has users or their representatives confirm the product does what they need. Regression runs come first, and a regression found during UAT is an escape the suite should learn from.

Why is it called a regression test?

The name comes from the software regressing, going back to a worse state, when a change breaks behaviour that used to work. A regression test reruns a check for that behaviour after the change, so the defect it looks for is one the product did not have before.

The Notarus team

The people who build Notarus. We write up the decisions behind the product when the reasoning is worth more than the changelog line.

Keep reading

Reports with the evidence attached.

Start free, one script tag.

<script src="…/widget.js" data-key="pb_pub_…">