Sanity testing is a quick, focused check performed after a small code change or bug fix to confirm that the change works and that the closely related functionality still behaves sensibly. If it passes, deeper testing continues. If it fails, the build goes back to development.
The name comes from the everyday sanity check: a fast test of whether something is reasonable before you invest more effort in it. In software, the question is simple. After this change, does the application still make sense? A sanity test answers it in minutes, so the team does not spend hours on regression or performance testing against a build that is obviously wrong.
Terminology varies. Some teams use "sanity testing" and "smoke testing" interchangeably, and some swap the definitions. This guide uses the most common distinction: smoke testing is a broad, shallow check that a build works at all, and sanity testing is a narrow check that a specific change works.
This guide covers how sanity testing works, how it differs from smoke and regression testing, a step-by-step process, a checklist you can copy, how to automate it in CI/CD, and what changes when AI writes more of your code. It is written for QA engineers, developers, and team leads.
TL;DR
30-second summary
Sanity testing is a narrow check run after a small change or fix. It confirms that the change works and that nearby functionality still makes sense, in minutes rather than hours. Run it after smoke testing and before regression testing, keep it to a handful of checks, and automate the ones you repeat.
- What it checks: The changed area, related functionality, and the critical flow that depends on it.
- When to run it: After a bug fix, a small feature change, a merge, a dependency update, or an AI-generated change.
- How it differs: Smoke testing asks whether the build runs at all, and regression testing asks whether anything else broke.
- How to keep it useful: Limit it to a few minutes, use a stable environment, and review the checks every release.
- New in 2026: More changes start as AI drafts, which makes a fast, independent check more valuable.
What a "sanity check" means in testing and beyond
People search for "sanity check" with different meanings in mind. The idea is the same in each: a quick test of whether something is reasonable before you build on it.
| Context | What a sanity check is | Example |
|---|---|---|
| Everyday use | A fast reasonableness check | A lunch bill that looks ten times too high |
| Software testing | Sanity testing: a short check after a small change or fix | After a login fix, confirming that login, password reset, and logout still work |
| Programming | A line of code that checks a value is in the expected range before the program continues | assert 0 <= discount <= 100 |
| Data and machine learning | A quick check that data or model output is plausible | Comparing row counts and null rates after a data load, or training a model on a tiny batch to confirm it can overfit before the full run |
The rest of this guide covers sanity testing in software.
Sanity vs. smoke vs. regression testing
The three are easy to confuse because they all run early and all aim to save time. The difference lies in the question each one answers.
| Aspect | Smoke testing | Sanity testing | Regression testing |
|---|---|---|---|
| Question it answers | Does the build run, and do the critical functions work? | Does this specific change work, and does nearby functionality still make sense? | Did the change break anything else? |
| Scope | Broad and shallow, across the main features | Narrow and focused on the changed area | Wide and deep, across the application |
| Trigger | Every new build | A small change, bug fix, or hotfix, after smoke testing passes | New features, fixes, and releases |
| Scripting | Usually scripted and often automated | Often unscripted or a short checklist, frequently derived from regression tests | Scripted and usually automated |
| Duration | Minutes | Minutes | Hours to days |
| If it fails | The build is rejected and further testing stops | The change goes back to development | Defects are fixed and the suite is rerun |
A rule of thumb: smoke testing checks the build, sanity testing checks the change, and regression testing checks everything else. Smoke tests are broad because the build is unknown, and sanity tests are narrow because the change is known. For the broad check, see our complete guide to smoke testing, and for the deep one, our post on why regression testing is important and our regression testing service.
Where sanity testing fits in the test flow

Smoke testing comes first, because there is no point checking a change in a build that does not run. If a sanity test fails, the change goes back to development. When the new build arrives, run the smoke tests again before repeating the sanity test, so you know the new build is stable. Sanity tests are usually unscripted or kept as a short checklist, and teams often derive them from existing regression tests.
When to run sanity testing
Run a sanity test whenever a change is small enough that you can name what it touches.
| Situation | What to check | Example |
|---|---|---|
| After a bug fix or hotfix | The bug is gone and nearby behavior still works | After a login fix, log in, reset the password, and log out |
| After a small feature change | The changed behavior and the flow it belongs to | A new payment option: select it, pay, and see the confirmation |
| After merging a branch | The merged areas still work together | Checkout still completes after the payments and profile changes merge |
| After a dependency or configuration update | The features that rely on it | After a library upgrade, the screens that use that library |
| After an AI-generated or agent-written change | The changed behavior, checked independently of the tool that wrote it | A refactored function: run its main cases by hand or with a short script |
| Before a demo or stakeholder review | The demo path from start to finish | Sign in, open the dashboard, run the main action |
When sanity testing is not enough
If a change is large, touches many modules, or has an unclear scope, a sanity test will not cover enough. Run broader regression testing instead, or on top of it, and do the same before a major release. Risk-based testing helps you decide how much to run.
How to do sanity testing, step by step

- Identify the change and what it touches. Read the ticket and the code diff, and list the features, screens, or endpoints affected. This sets the scope.
- Choose a small set of checks. Pick three to ten, covering the change itself, the closest related behavior, and the critical flow that depends on it.
- Confirm the build is stable. Run smoke tests first, in a stable environment with reliable test data, so a failure points to the change and not to the setup.
- Run the checks and time-box them. Use a short checklist or an automated set, and aim for minutes, not hours.
- Decide and report. If everything passes, deeper testing continues. If anything fails, reject the change, and attach logs, screenshots, and the exact steps. Our guide to writing a good bug report shows what to include.
- Keep what works. Save useful checks for next time, and automate the ones you repeat. See automated vs manual testing for how to choose.
Sanity testing checklist
Copy this table and trim it to the change in front of you. A sanity checklist should fit on one screen.
| Area | What to check |
|---|---|
| The change itself | The fixed bug no longer reproduces, the new behavior matches the ticket, and the error messages related to the change are correct |
| Adjacent functionality | Related screens, endpoints, and settings still work, and data saves and loads correctly |
| Critical user flow | Sign-in works, main navigation works, the core action completes (checkout, search, or upload), and sign-out works |
| Data and integrations | Records are created and updated correctly, key API responses return the expected status and fields, and payment or other third-party calls succeed in the sandbox |
| Interface and platform | The page or screen loads without console errors, works in the main browser or on the main device, and shows no layout break |
| Quick non-functional checks | No obvious slowdown, no crashes, and no new errors in the logs |
Example: Sanity testing a login fix
A bug report says users whose email address contains a plus sign cannot log in. Developers fix it and deploy a new build to the test environment. After the smoke tests pass, a tester runs this sanity check:
- Log in with a plus-sign email address. This is the fix itself.
- Log in with a normal email address to confirm nothing else changed.
- Request a password reset for the plus-sign address and confirm the email arrives.
- Refresh the page and confirm the session persists.
- Log out and log back in.
- Sign up with a new plus-sign address to confirm the same rule holds on registration.
The whole check takes a few minutes. If step 1 fails, the fix did not work. If step 2 fails, the fix broke something else. In either case the build goes back to development before anyone starts regression testing.
Automating sanity tests in CI/CD

Automation pays off for the checks you repeat on every change. A common setup looks like this:
- Tag the checks. Most frameworks can group tests, for example with pytest markers or JUnit tags. Tag your sanity checks so the pipeline can run only those.
- Select by changed area. Run the sanity checks that map to the files or services a change touches, instead of the same set every time.
- Run after smoke, before the long suites. Make sanity a gate. A failure stops the pipeline before regression and performance tests start.
- Keep it fast. Set a time limit of a few minutes, and move slower checks to the regression suite.
- Keep it stable. A flaky sanity test teaches people to ignore failures. Fix or quarantine flaky checks, and see our guides to flaky UI tests and false positives and negatives.
Our CI/CD services and test automation team can help you set up these gates.
Sanity testing in the age of AI-written code
AI assistants and agents are now part of everyday change flow. GitHub's Octoverse 2026 reports that more than 40% of pull requests started with an agent's first draft by September 2026, up from 17% in March. In Stack Overflow's 2026 Developer Survey, 69.3% of respondents said plausible but wrong code was among the AI mistakes that cost them the most time, and 54.2% named code that is hard to review. More small changes and harder reviews make a quick, independent check of each change more valuable.
- Check the change, not the author. Run the same sanity checklist on an AI-generated change as on any other.
- Decide what must work before you accept the change. Do not let the tool that wrote the code also write the only test of it.
- Keep a sanity set for AI features. If your product includes a chatbot or another AI feature, keep a short set of known questions with expected behavior and run it after every prompt, model, or configuration change. A golden dataset is the longer version, and our guide on how to test an AI chatbot covers the method.
For more, read our guides to AI hallucinations in software testing and AI in software testing.
Stop broken builds before they cost you a test cycle
TestDevLab's QA engineers build sanity and smoke checks into your CI/CD pipeline, and review AI-generated changes before they reach deeper testing. You get fast feedback and fewer wasted test cycles.
Strengths and limits of sanity testing
| Strengths | Limits |
|---|---|
| Tells you in minutes whether a change is worth deeper testing | Narrow, so it does not uncover deep or hidden defects |
| Focuses effort on the change, where the risk sits | May miss side effects outside the chosen checks |
| Needs little time and little tooling | Not enough on its own for large changes or releases |
| Easy to start with a short checklist | Unscripted checks depend on the tester's judgment |
Best practices for sanity testing
- Keep the set small and relevant. A handful of checks per change is enough.
- Tie checks to features or requirements. You should always know what each check covers.
- Maintain checks with the code. Update them when the product changes, and delete the ones that no longer matter.
- Make them a gate in CI/CD. Tag the checks and give them their own pipeline stage.
- Track a few numbers. Watch how long the set takes to run, how often it fails, and how many defects it catches compared with those found later. Our post on QA performance metrics has more ideas.
- Share results straight away. Post pass or fail where the team will see it, so a failed build gets attention quickly.
The bottom line
Sanity testing is a small habit with an outsized payoff. A few minutes of checking after each change tells you whether the change works and whether the surrounding product still makes sense, before anyone spends hours on deeper testing. Keep the set small, run it after smoke testing, automate what you repeat, and review it every release. In 2026, with more changes starting as AI drafts, that fast, independent check is worth more than before.
FAQ
Most common questions
What is sanity testing?
Sanity testing is a quick, focused check performed after a small code change or bug fix to confirm that the change works and that the closely related functionality still behaves sensibly.
What is the difference between sanity testing and smoke testing?
Smoke testing checks whether a build runs and its critical functions work, so it is broad and shallow. Sanity testing checks whether a specific change works, so it is narrow and focused. Run smoke tests first, then sanity tests. Some teams use the two terms interchangeably.
What is the difference between sanity testing and regression testing?
Sanity testing is a short check on a changed area. Regression testing is a wide, deep check that existing functionality still works across the application. A passing sanity test tells you regression testing is worth starting.
When should you do sanity testing?
After a small code change, bug fix, hotfix, merge, or dependency update, once the smoke tests have passed and before regression testing begins. It is also useful before a demo.
Is sanity testing manual or automated?
Either. Small teams often use a short manual checklist. Larger teams automate the checks they repeat and run them as a gate in CI/CD.
How long should sanity testing take?
A few minutes. If it takes much longer, the set has probably grown into regression testing and should be trimmed.
What is a sanity check in programming?
It is a line of code that verifies a value is within an expected range or state before the program continues, such as asserting that a discount is between 0 and 100.
Catch small breaks before they become big ones
TestDevLab's functional testing team builds sanity checks straight into your pipeline. A quick check after a fix costs minutes, and skipping it can cost a full regression cycle.





