1. Home
  2. Blog
  3. Software Testing

Software Testing

Verification vs Validation: Tested Example and Comparison Table

Verification checks that you built the product right; validation checks that you built the right product. Learn the difference with a tested coupon example where every unit test passed but five of six shoppers failed, plus a comparison table, techniques and interview answers.

9 min read
Verification vs validation in software testing: real example and comparison table

Key takeaways

  • Verification asks: did we build the product right, according to the specification?
  • Validation asks: did we build the right product for the people who will use it?
  • Verification is mostly reviews, inspections, static analysis and spec-based tests. Validation needs the working product in front of real users or real scenarios.
  • In our example, all 6 spec tests passed, yet only 1 of 6 shoppers could use the coupon. You need both.

“Verification vs validation” is one of the most common questions in testing interviews, and one of the most often memorised without being understood. The definitions sound similar, and many teams use the words interchangeably. The difference is practical, though: a product can pass every check against its specification and still fail the people it was built for.

This guide explains both terms in plain language, compares them side by side, and walks through a small Python example we actually ran, where verification passed and validation failed. If you are new to the testing process, start with our software testing life cycle guide.

Verification vs validation: the short answer

A widely quoted pair of questions, from software engineering pioneer Barry Boehm, sums it up:

  • Verification: “Are we building the product right?”
  • Validation: “Are we building the right product?”

Verification compares work products against specifications: requirements, designs, coding standards. Validation compares the finished product against real needs: what users, customers and the business actually require in their real environment. A specification can be wrong or incomplete, and only validation will catch that.

What is verification in software testing?

Verification is the process of checking that each work product meets the requirements and standards set for it. The ISTQB glossary describes it as confirming, with objective evidence, that specified requirements have been fulfilled. It can start on day one, long before any code runs.

Typical verification activities:

  • Reviewing requirements for clarity, completeness and testability.
  • Design and architecture reviews.
  • Code reviews, walkthroughs and formal inspections.
  • Static analysis and linting.
  • Unit and integration tests written directly from the specification.

Much of verification is static: it examines documents and code without executing the product. That is why it finds defects early, when they are cheapest to fix, a key idea behind shift-left testing.

What is validation in software testing?

Validation checks that the product fulfils its intended use in its intended environment. It is dynamic: someone has to run the software and judge the result against real needs, not just against the written spec.

Typical validation activities:

  • System testing with realistic end-to-end scenarios.
  • User acceptance testing by customers or business users.
  • Usability testing, beta tests and pilot releases.
  • Exploratory testing that asks “would a real person get stuck here?”
  • Checking production feedback, analytics and support tickets.

Verification vs validation comparison table

Aspect Verification Validation
Question Built the product right? Built the right product?
Compared against Specifications, designs, standards User needs and intended use
Type Mostly static Dynamic
Needs running code? Not always Yes
When Throughout, starting with requirements Once a working build exists, mainly later
Methods Reviews, inspections, static analysis, spec-based tests System tests, UAT, usability, beta tests
Done by Developers, testers, reviewers Testers, users, customers, product owners
Finds Deviations from the spec Wrong or missing requirements
Cost of defects found Lower, found early Higher, found late

A tested example: the coupon field

Here is a small, realistic case we built and ran with Python 3.13.6 and pytest 9.2.0. The written requirements were:

  • R1: a coupon code is exactly 6 uppercase letters A to Z.
  • R2: a valid code gives 10 percent off.

The developer implemented exactly that:

import re

def apply_coupon(total, code):
    if not re.fullmatch(r"[A-Z]{6}", code):
        raise ValueError("invalid coupon")
    return round(total * 0.9, 2)

Verification came first. A quick static check of the file found one function and one raise statement and flagged a missing docstring, the kind of thing a code review catches. Then we wrote tests straight from R1 and R2:

def test_r1_accepts_six_uppercase():
    assert apply_coupon(100, "SAVEME") == 90.0

@pytest.mark.parametrize("bad", ["SAVE", "SAVEMEE", "SAVE12", ""])
def test_r1_rejects_wrong_format(bad):
    with pytest.raises(ValueError):
        apply_coupon(100, bad)

def test_r2_ten_percent():
    assert apply_coupon(59.99, "WINTER") == 53.99

# 6 passed in 0.01s

Every test passed. By the specification, the feature is correct.

Validation came next. We fed the function what six shoppers in a hallway usability session typed after reading the code WINTER on a printed flyer (sample data):

'WINTER'    accepted
'winter'    rejected
' WINTER'   rejected
'WINTER '   rejected
'Winter'    rejected
'WIN TER'   rejected
1 of 6 shoppers got their discount

Five of six realistic inputs were rejected by a feature that passed all its tests.

Why verification passed and validation failed

Nothing was wrong with the code relative to the spec. The spec was wrong: it described the storage format of a code, not how people enter one. People type in lower case, paste with spaces and capitalise the first letter. Verification cannot catch that, because it only checks consistency with the written requirement. Validation compares the product with reality, so it exposed the gap immediately.

This is the core lesson: verification finds bugs in the implementation, while validation finds bugs in the requirements and in the understanding of the user.

Tip: when a validation failure appears, fix the requirement first, then the code, then add tests for the new rule. Otherwise the next refactor can bring the bug back.

Fixing the gap and verifying again

We updated R1 to say that input is trimmed, spaces removed and letters upper-cased before checking, and changed one line:

code = code.strip().upper().replace(" ", "")

Rerunning both checks: 6 of 6 shoppers got their discount, and the original 6 verification tests still passed. The loop from validation back to requirements and verification is normal and healthy. Add the shopper inputs to the test suite so verification now covers what validation taught you, and rerun it on every change as part of regression testing.

Verification and validation in the V-model

The V-model makes the relationship visible. The left side of the V moves down from business requirements to system requirements, design and code. Each step is verified against the step above it through reviews. The right side climbs back up through unit, integration, system and acceptance testing. Unit and integration tests mainly verify the design, while system and acceptance testing validate the product against the original needs.

Agile teams do the same thing in short loops. Code review, unit tests and checks against acceptance criteria verify each story. Sprint demos, user feedback and production metrics validate it.

Techniques at a glance

Verification techniques Validation techniques
Requirement reviews End-to-end system testing
Design reviews and walkthroughs User acceptance testing
Code reviews and inspections Usability testing
Static analysis and linters Alpha and beta testing
Spec-based unit tests Exploratory testing with personas
Traceability matrix checks A/B tests and production analytics

Who does verification and validation?

Verification is shared by everyone who produces work products: developers review each other’s code, testers review requirements for testability, and architects review designs. Validation needs people who understand the real use: product owners, business users, customers and testers who think like them. Independent testers are valuable in both, because a fresh view spots assumptions the authors cannot see.

Common mistakes

  • Treating a green test suite as proof of quality. It proves conformance to what was written, nothing more.
  • Leaving validation to the end. Show prototypes and early builds to real users; late validation failures are expensive.
  • Skipping verification because “users will test it”. Users find problems slowly and at high cost.
  • Not feeding validation findings back into tests. Every real-world failure should become a requirement and a test case.
  • Confusing the two in reports. Say which question each activity answers so stakeholders know what has been checked.

How to answer in an interview

Keep it short and give an example: “Verification checks that we built the product right, against the specification, mostly through reviews, static analysis and spec-based tests, and it can start before code exists. Validation checks that we built the right product for the user, by running the software in realistic conditions, for example in system testing and UAT. A feature can pass verification and fail validation if the requirement itself was wrong.” Then mention the coupon example. Concrete stories beat memorised definitions. More practice questions are in our guide to writing test cases.

Final thoughts

Verification and validation are two halves of quality. Verification keeps the implementation faithful to the plan, cheaply and early. Validation checks that the plan itself serves real people. Our coupon feature passed every verification test and still failed five of six shoppers until validation revealed the faulty requirement. Do both, and let what validation teaches you flow back into the specs and the test suite.

Frequently asked questions

What is the main difference between verification and validation?

Verification checks that the product matches its specification, or building the product right. Validation checks that the product meets real user needs, or building the right product.

Which comes first, verification or validation?

Verification usually starts first, because requirements and designs can be reviewed before any code exists. Validation needs a working build, so it happens later, although early prototypes can be validated with users too.

Is unit testing verification or validation?

Unit testing is mainly verification, because it checks code against the design or specification. System testing and user acceptance testing are mainly validation.

Is verification static or dynamic testing?

Verification is mostly static, using reviews, inspections and static analysis, although spec-based tests that run code also verify. Validation is dynamic and requires executing the software.

Can a product pass verification but fail validation?

Yes. If a requirement is wrong or incomplete, the code can match it perfectly and still fail users. In our coupon example every spec test passed while five of six shoppers were rejected.

Keep learning

Work with Stack Quora

Need help with testing, WordPress or SEO?

We help teams ship better software and grow their sites. Tell us what you are working on and we will suggest a clear next step.

Keep reading

More guides on testing, AI & modern development

Enjoyed this article? Pick a topic and jump straight into our newest tutorials.

Artificial Intelligence

Softmax Function Explained: Formula, Python Code and Stable Version

The softmax function explained: formula, worked example, NumPy code, the stable version that avoids NaN, temperature, cross-entropy and softmax vs…

Read article →
Software Development

CORS Explained: Preflight Requests, Headers and How to Fix CORS Errors

CORS explained: origins, simple and preflight requests, the response headers your server must send, credentials, and how to fix common…

Read article →
DevOps

Git Diff Explained: Staged Changes, Branches and Commits

Git diff explained: read the output, compare unstaged and staged changes, commits and branches, two dots vs three dots, and…

Read article →
Test Automation

Pytest Xdist: Run Tests in Parallel and Cut Test Time

Run pytest tests in parallel with pytest-xdist: install, the -n option, distribution modes, real timings and how to fix shared-state…

Read article →
Software Testing

Verification vs Validation in Software Testing: Example and Table

Verification vs validation in software testing explained with a comparison table and a tested coupon example where every spec test…

Read article →
Databases & SQL

SQL CAST Explained: Convert Data Types With Tested Examples

SQL CAST explained with tested examples: text to number, truncation, integer division, numbers stored as text, dates, bad input and…

Read article →
Databases & SQL

SQL DISTINCT: How to Remove Duplicate Rows (and Its Traps)

SQL DISTINCT explained with tested queries: one and many columns, NULLs, COUNT DISTINCT, DISTINCT vs GROUP BY, the SUM DISTINCT…

Read article →
Software Development

JavaScript Reduce Explained: 12 Practical Examples

JavaScript reduce explained step by step with 12 practical examples: sums, tallies, grouping, Maps, pipelines, sequential promises and the empty…

Read article →
Software Development

Python Random Module: randint, choice, seed and More

The Python random module explained: randint, randrange, choice, choices, sample, shuffle, seed, weights and when to use secrets instead, with…

Read article →
Software Development

Python Slicing Explained: Start, Stop and Step With Examples

Python slicing explained with start, stop and step, negative indexes, reversing, copying and slice assignment, with tested examples and a…

Read article →
Artificial Intelligence

Levenshtein Distance: Formula, Worked Table and Python Code

Levenshtein distance explained: the edit operations, the dynamic programming table for kitten and sitting, Python code with two-row memory, normalised…

Read article →
Software Development

URL Encoding Explained: Spaces, Plus Signs and UTF-8

URL encoding explained with tested Python and JavaScript code: percent encoding, reserved characters, %20 vs plus, UTF-8 bytes, encodeURI vs…

Read article →
DevOps

Gitignore: Patterns, Negation and Fixing Tracked Files

A tested gitignore guide: pattern rules, leading and trailing slashes, negation with !, the ignored parent folder trap, git check-ignore…

Read article →
Software Testing

Acceptance Criteria: Given When Then Examples and Checklist

How to write acceptance criteria testers can run: rule-based and Given When Then formats, a worked discount code example turned…

Read article →
Software Testing

State Transition Testing: Diagram, Table and Example

State transition testing explained with a login lockout example: states, events, the diagram, the state table, valid and invalid transitions,…

Read article →
Databases & SQL

Second Highest Salary in SQL: 5 Tested Ways and the Tie Trap

Find the second highest salary in SQL five ways: MAX subquery, LIMIT OFFSET, DENSE_RANK, a correlated subquery and per department,…

Read article →
Databases & SQL

SQL ROW_NUMBER: Top N per Group, Dedupe and Pagination

SQL ROW_NUMBER explained with tested queries: PARTITION BY, top N per group, deleting duplicates, pagination, the tie trap and how…

Read article →
Software Development

JavaScript Set: Union, Intersection and Removing Duplicates

JavaScript Set explained with tested examples: add, has, delete, deduplicating arrays, the new union and intersection methods, equality rules and…

Read article →
Test Automation

Python Unittest: Assert Methods, setUp and Mocks With Examples

A practical Python unittest tutorial: TestCase, assert methods, setUp and tearDown, subTest, skips, expected failures and mock, with a test…

Read article →
Artificial Intelligence

Jaccard Similarity: Formula, Python, MinHash

Jaccard similarity measures overlap between two sets as intersection over union. Work the formula, compute it in Python for words…

Read article →
DevOps

Git Hooks: Pre-commit and Commit-msg Examples

Git hooks run scripts at key moments such as commit and push. See tested pre-commit, commit-msg and prepare-commit-msg hooks, sharing…

Read article →
Test Automation

API Testing in Python: Pytest + Requests Suite

Build an API testing suite in Python with pytest and requests: fixtures, status codes, headers, JSON schema validation, CRUD flows,…

Read article →
Software Testing

Test Design Techniques: 9 Methods + Examples

Test design techniques help you write fewer tests that catch more bugs. Learn 9 black-box, white-box and experience-based methods with…

Read article →
Databases & SQL

SQL Temporary Table: Create, Use and Drop It

SQL temporary tables store interim results for one session. Learn syntax for SQL Server, PostgreSQL, MySQL, Oracle and SQLite, session…

Read article →
Databases & SQL

SQL CROSS JOIN: Every Combination + Examples

SQL CROSS JOIN returns every combination of rows from two tables. See the row math, product variants, calendar grids that…

Read article →
Artificial Intelligence

TF-IDF Explained: Formula and Worked Example

TF-IDF scores a word by how often it appears in a document and how rare it is across all documents….

Read article →
DevOps

Git Tag: Create, Push and Delete Release Tags

Git tag explained with tested commands: annotated vs lightweight tags, listing and sorting, pushing with follow-tags, deleting local and remote…

Read article →
Test Automation

Pytest Coverage: pytest-cov and Branch Gaps

Measure pytest coverage with pytest-cov: term-missing reports, branch coverage, HTML reports, pyproject settings and a fail-under gate for CI, with…

Read article →
Software Testing

Error Guessing in Testing: Checklist + Demo

Error guessing uses tester experience to predict where code breaks. Get a ready checklist of risky inputs, a step by…

Read article →
Artificial Intelligence

BM25 Explained: How Keyword Search Ranks Results, With Python Code and Hybrid Search

BM25 explained with a pure Python implementation we ran: the formula, IDF, term saturation, the k1 and b parameters, why…

Read article →
DevOps

Git Bisect Explained: Find the Commit That Broke Your Code, Manually or Automatically

Git bisect explained with a tested repository: find the one bad commit among 41 in 5 test runs, automate it…

Read article →
Test Automation

pytest Markers Explained: Custom Marks, skip, skipif, xfail and -m Filters

pytest markers explained with a tested suite: register custom marks, run only smoke tests with -m, combine filters with and,…

Read article →
Software Testing

Positive vs Negative Testing: Differences, 24 Real Test Cases and a Checklist

Positive vs negative testing explained with a real signup form: 6 positive and 18 negative test cases run in pytest,…

Read article →
Artificial Intelligence

Cosine Similarity Explained: Formula, Worked Example and Python Code

Cosine similarity explained simply: the formula, a worked example by hand, pure Python and NumPy code, cosine vs Euclidean distance…

Read article →
DevOps

Git Squash Commits: 4 Easy Ways, Tested Step by Step (rebase -i, reset, merge)

Git squash commits explained with 4 tested methods: interactive rebase, reset –soft, merge –squash and fixup with autosquash. Before-and-after logs,…

Read article →
Test Automation

pytest parametrize Explained: 7 Patterns with Tested Examples

pytest parametrize explained with 7 tested patterns: basic cases, readable ids, stacked decorators, pytest.param with xfail and skip, indirect fixtures…

Read article →