Great work!

XP to next level

BugEater

Sanity Test — The Sanity Check

Learning Objectives

By the end of this lesson, you'll be able to:

  • 🎯 Define sanity testing and explain when it's triggered
  • 🔍 Structure a focused sanity test from a bug report
  • 🧠 Understand the difference between "narrow and deep" vs "wide and shallow"
  • ✅ Know when to escalate if a fix didn't hold

The Big Idea

A developer just marked a bug as "Fixed." Should you trust it?

Not blindly. But you also don't need to run a full regression every time a single bug gets closed.

You need a sanity test — a quick, focused check that answers one question: "Is this specific bug actually gone, and does the logic around it still make sense?"

The name says it all: you're checking that the fix hasn't driven the system "insane." That the logic in this particular area is rational and working as expected.

What Is a Sanity Test?

A sanity test is a narrow, deep check on a specific area that was just changed or fixed.

  • Narrow = you're focused on one specific area or feature
  • Deep = you go through the scenarios in that area more thoroughly than a smoke test

Sanity testing is triggered by a specific fix or change. It's not scheduled — it happens reactively, every time a developer says "this is done."

Key characteristics:

  • It's specific to a single area
  • It's based on the bug report or the change description
  • It's deeper than smoke but smaller than regression
  • It's typically informal — no need for a full test plan document

How to Structure a Sanity Test

The best source for your sanity test is the original bug report. It contains:

  1. Steps to reproduce the problem → your test steps
  2. Expected behavior → what you should see after the fix
  3. Actual behavior (the old broken behavior) → what you should NOT see anymore

A simple sanity test workflow:

  1. 📋 Open the bug report
  2. 🔁 Follow the reproduction steps exactly
  3. ✅ Verify that the expected result now happens
  4. 🔍 Check 1–2 adjacent scenarios (slightly different inputs or paths)
  5. ✅ If all pass: close the bug, mark it as "Verified"
  6. ❌ If it still fails: reopen the bug, add a comment with your test results

What sanity testing is NOT

A sanity test is not a regression sweep. You're not checking every feature in the product — you're laser-focused on this one fix.

Imagine a surgeon who just repaired a torn ligament. They check: "Does the knee move correctly? Is there swelling? Are the sutures holding?" They don't check the patient's vision, blood pressure, and hearing at the same time.

Real-World Example

Bug #284: "Password reset email is not sent when user requests it."

After the fix, your sanity test:

  1. Go to the login page
  2. Click "Forgot Password?"
  3. Enter a valid registered email address
  4. Click "Send Reset Link"
  5. Check your email inbox → ✅ email arrives within 30 seconds
  6. Open the email → ✅ the reset link looks correct
  7. Click the link → ✅ it opens the password reset form
  8. Adjacent scenario: enter an unregistered email → ✅ error message appears: "If this email is registered, you'll receive a link"

Not part of this sanity test:

  • ❌ Testing the login form itself
  • ❌ Testing the checkout flow
  • ❌ Testing any other email-triggered function

Pro Tips

💡 Sanity tests don't need documentation. Unlike regression checklists, a sanity test is ad-hoc. You can do it mentally or with quick notes. Speed is the point.

💡 Check adjacent paths, not the whole product. After verifying the fix itself, test 1–2 closely related scenarios. A fix that works in the happy path might still fail on a slight variation.

💡 Read the bug report carefully before testing. Developers sometimes fix a different manifestation than the one you originally reported. Make sure you're testing the same scenario.

Summary

  • 🧠 A sanity test is triggered by a specific fix, not a scheduled event
  • 🎯 It's narrow and deep — focused on one area, not the whole product
  • 📋 Start from the original bug report: reproduction steps = your test steps
  • ✅ Pass: close the bug | ❌ Fail: reopen with test details
  • 🚫 It's NOT a regression sweep — don't get distracted by other areas

Up next: Lesson 1.3 — Smoke vs Sanity: a side-by-side comparison and a decision framework to help you choose the right test type instantly. 📊

Quiz

What triggers a sanity test?

Sanity testing is "narrow and deep." What does this mean in practice?

Which statement correctly distinguishes sanity from regression testing?

A bug was filed: "The password reset email is not sent." After the fix, you run a sanity test. Which scenario is NOT part of this sanity test?