Skip to content
Tutorials Center
My learning

Topics

Lesson 7 of 60 ยท Testing Fundamentals

Smoke, Sanity and Regression Testing

Learn the difference between smoke, sanity and regression testing, plus retesting, how to choose regression cases, and when each check runs in a release.

Every new build raises the same questions. Is it even worth testing? Did the one thing we fixed actually get fixed? And did the fix quietly break something that used to work? Three named checks answer these questions: smoke testing, sanity testing and regression testing, with a close relative called retesting. They are among the most-used words in a tester's day, and also among the most confused, so this lesson separates them with plain definitions and runnable examples.

All of them are types of testing chosen by purpose (see Test Types), not levels. You can run any of them at unit, integration or system level.

Smoke testing: does it start at all?

A smoke test is a small, shallow set of checks on a fresh build that answers one question: "is this build stable enough to test further?" The name comes from hardware: power a new board on and see whether smoke comes out.

Typical smoke checks for a web shop are: the site loads, a user can log in, search returns something, an item can be added to the cart, the checkout page opens. Each check is broad but shallow; none checks the details.

Key traits:

  • Run first, on every new build, before any deeper testing.
  • Fast: minutes, not hours. Usually automated and run by the pipeline.
  • Pass or fail gate. If the smoke test fails, the build is rejected and sent back; nobody wastes a day testing something that cannot log in.
  • Covers the critical paths across the whole product, not one feature in depth.

Smoke testing is also called a build verification test (BVT) or "confidence test". After a deployment it is run again against the real environment as a post-deployment or health check.

Sanity testing: did this change work?

A sanity test is a narrow, deep check done on a build that has just received a small change, such as a bug fix or a tiny feature. It answers: "does the changed area behave sensibly, so that a full test is worthwhile?"

Suppose the "apply discount code" bug was fixed. A sanity check tries valid codes, an expired code and an empty code, looks at the cart total, and perhaps glances at the neighbouring checkout steps. It does not re-run the whole shop.

  • Focused: only the changed area and its close neighbours.
  • Usually unscripted or lightly scripted, often done manually by the tester who knows the change.
  • Done on a relatively stable build, after smoke testing, when time is short.

The mnemonic: smoke is wide and shallow ("does the whole thing breathe?"), sanity is narrow and deep ("does this change make sense?").

Retesting: is the exact defect gone?

Retesting (also called confirmation testing) means running the same test that failed again after the developer says the defect is fixed, using the same steps and data. If it now passes, the defect can be closed (see the defect lifecycle).

Retesting asks about the known bug. It is planned from the failed test case, so it is specific and scripted.

Regression testing: did we break anything else?

Regression testing re-runs previously passing tests to find out whether a change has damaged existing behavior. A "regression" is a feature that used to work and no longer does. Changes cause them in surprising ways: a fixed rounding function is shared by invoices, a renamed field breaks an export, a new library version changes date handling.

Because it covers a lot, regression testing is the main reason to invest in automation: the same tests run again and again, release after release.

Choosing what goes into the regression suite is a judgment call. Good candidates are:

  • Tests for critical business flows (login, payment, core data entry).
  • Tests for features that failed before (defects cluster).
  • Tests for areas that are changed often or are tightly coupled to what changed.
  • Stable, repeatable tests that give the same answer every time.

When time is short, teams run a subset: only tests related to the changed modules (selective or impact-based regression), or tests prioritized by risk (see Risk-Based Testing). When time allows, they run the complete suite, for example before a major release.

How the four checks differ

Smoke Sanity Retesting Regression
Question Is the build testable? Does the change work sensibly? Is this defect fixed? Did anything else break?
Scope Wide and shallow Narrow and deep One failed test Wide, many existing tests
When Every new build, first After a small change or fix After a defect is fixed After any change, before release
Scripted Yes, often automated Often not Yes (the failed test) Yes, usually automated
Result Accept or reject build Continue or stop testing Close or reopen the defect Report new defects

Be aware that some books and companies swap definitions, especially for sanity testing, which some people use for "a quick regression". When you join a team, check what they mean.

A build moving through the checks

flowchart LR
  B["New build"] --> S{"Smoke test"}
  S -- fail --> R["Reject build"]
  S -- pass --> C{"Small fix?"}
  C -- yes --> SA["Sanity test<br/>of changed area"]
  C -- no --> FT["Full feature tests"]
  SA --> RT["Retest the fixed defect"]
  FT --> RG["Regression suite"]
  RT --> RG
  RG --> REL["Release decision"]

Smoke gates the build, sanity and retest check the change, regression protects everything else.

Try it: a smoke gate

This stand-in models a smoke suite as a list of fast checks run against a fake build. It stops at the first critical failure, as a pipeline gate would.

JS A smoke gate for a fake build

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Change checkoutPageOpens to true and run it again: the gate opens and the build is accepted. Notice the checks do not look at prices or messages; they only prove the main paths are alive.

Try it: pick the regression tests for a change

This stand-in tags each test with the modules it touches and a risk score, then selects a subset for a change in the pricing module, within a time budget.

JS Selecting a regression subset

Press Run (or Ctrl + Enter) to see the console output here.

No output.

The skipped tests are the price of selective regression. A careful team writes down what was not run, because that is the residual risk.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. A new build is deployed and the login page throws an error. Which check should have caught this first, quickly and cheaply?

    Smoke tests are fast, broad checks of the critical paths, run first on every build to decide whether deeper testing is worthwhile.
  2. 2. A tester runs the exact steps of a failed test again after the developer reports a fix. What is this called?

    Retesting re-runs the test that failed to confirm that the specific defect has been fixed.
  3. 3. Which statement best describes regression testing?

    Regression testing protects existing behavior. It is repeated after every change and complements, not replaces, retesting.
  4. 4. Which pair correctly contrasts smoke and sanity testing?

    Smoke covers the critical paths of the whole build at a shallow level; sanity digs into the changed area.

Summary

  • Smoke testing is a quick, wide, shallow check that decides whether a build deserves further testing.
  • Sanity testing is a narrow, deep check of a small change or fix.
  • Retesting re-runs a failed test to confirm the defect is fixed; regression testing re-runs old passing tests to find side effects.
  • Build regression suites from critical flows, defect-prone areas and frequently changed code, and record what was skipped.
  • Definitions vary slightly between companies, so confirm the local meaning.

Next up: Black-Box, White-Box and Grey-Box Testing.