Four different questions about a system, each needing its own kind of test.
π Where this lives: open the CI configuration of any serious project and you will find these levels as named stages: a fast unit job that runs on every push, an integration job with a real database, and a slower end-to-end job that drives a browser. They are separated because they answer different questions and cost wildly different amounts β a unit test runs in microseconds, a browser test in seconds. Getting the proportions wrong is the single most common reason a test suite becomes too slow to run, at which point it stops being run at all. Search "test pyramid unit integration end to end proportions".
What testing is and is not
TESTING is the process of executing a program with the intent of
FINDING ERRORS. (Myers's definition, and the emphasis is
deliberate.)
A GOOD TEST CASE is one with a high probability of finding an
as-yet-undiscovered error. A SUCCESSFUL TEST is one that
uncovers an as-yet-undiscovered error.
READ THAT AGAIN, because it inverts the intuition: a test that
passes has told you almost nothing; a test that FAILS has
found you a defect while it is still cheap to fix. A tester
whose tests all pass has either a perfect program or a weak
test suite, and the second is far more likely.
DIJKSTRA'S OBSERVATION, the fundamental limit:
"Testing shows the PRESENCE, not the ABSENCE of defects."
Exhaustive testing is impossible for any realistic program β
a function taking two 32-bit integers has 2^64 β 1.8 Γ 10^19
input combinations. At a million tests per second that is
585,000 YEARS. Testing is therefore always SAMPLING, and test
design is the art of choosing a sample that finds defects.
VERIFICATION vs VALIDATION (recall the requirements topic):
VERIFICATION "Are we building the product RIGHT?"
Does it conform to its specification?
VALIDATION "Are we building the RIGHT product?"
Does it meet the customer's actual needs?
A system can pass every verification test and fail validation
entirely β it correctly implements the wrong thing.
ERROR, FAULT, FAILURE β the precise vocabulary:
ERROR a human mistake (the developer's misunderstanding)
FAULT the resulting defect in the code (also "bug")
FAILURE the observable incorrect behaviour when the fault
is executed
A fault that is never executed causes no failure β which is
why faults can lie dormant for years.
The four levels
1. UNIT TESTING
Individual components are tested to ensure they operate
correctly. Each component is tested INDEPENDENTLY, without
other system components. A unit may be a function, a
procedure, a class, or a small module.
Β· normally done by the DEVELOPER who wrote the code
Β· WHITE-BOX oriented β the tester sees the internals
Β· needs DRIVERS (a stub main program that calls the unit and
supplies test data) and STUBS (dummy replacements for the
units this unit calls)
Β· fast, cheap, precise: when a unit test fails you know
exactly where the fault is
Β· WHAT IT CANNOT FIND: any defect in the interaction between
units, which is where a large share of real defects live
2. INTEGRATION / MODULE TESTING
Testing of a collection of dependent components. Exposes
faults in the INTERFACES and in the interaction between
integrated components.
THREE STRATEGIES:
TOP-DOWN start with the high-level control module,
stub out the modules below, and replace stubs
progressively downward.
β major design faults found early
β an early skeleton of the system can be
demonstrated
β needs many stubs; low-level utilities are
tested last, and they are heavily used
BOTTOM-UP start with the lowest-level utilities, using
drivers, and work upward.
β no stubs needed; utilities well tested
β the control structure β where design faults
concentrate β is tested LAST
β no working program exists until near the
end
SANDWICH / both at once, meeting in the middle at a
BIG-BANG target layer. BIG-BANG (integrate everything
at once) is named for completeness and is
almost always a mistake: when it fails, you
have no idea which interface is at fault.
REGRESSION TESTING belongs here too: re-running existing
tests after a change, to confirm the change broke nothing.
3. SYSTEM TESTING
Testing of the complete system prior to delivery, as an
integrated whole. Concerned with validating that the system
meets its functional AND non-functional requirements.
BLACK-BOX oriented, done by an independent test team.
Includes the specialised kinds:
FUNCTION TESTING does it do what the spec says?
PERFORMANCE / STRESS behaviour at and beyond the
specified load. Stress testing
deliberately pushes past the design
limit to see HOW it fails β
gracefully, or catastrophically?
SECURITY TESTING can protection be breached?
RECOVERY TESTING forces failure and verifies
recovery and data integrity
CONFIGURATION TESTING across supported platforms
COMPATIBILITY / with other systems it must work
INTEROPERABILITY alongside
USABILITY TESTING with real users
4. ACCEPTANCE TESTING
Testing by the CUSTOMER to decide whether to accept the
system. Uses REAL customer data, not test data β and this
regularly finds defects everything else missed, because real
data contains cases nobody imagined.
ALPHA TESTING conducted at the developer's site with
the customer present; used for bespoke
systems
BETA TESTING the software is released to a set of real
users at their own sites, who report
problems; used for generic products
The output is an accept/reject decision, so this level is
contractual rather than merely technical.
A FIFTH LEVEL, sometimes listed: RELEASE / DEPLOYMENT TESTING
β testing a particular release in its production-like
environment, including installation, upgrade and rollback.
The V-model, and how much each level costs
THE V-MODEL β the standard picture of how the levels correspond
to development phases. Each development phase has a matching
test level, and the tests for a phase are designed AS the phase
is done, not afterwards.
requirements ββββββββββββββββββΆ acceptance testing
β² β±
system spec βββββββββββββββΆ system testing
β² β±
architecture βββββββββΆ integration testing
β² β±
detailed design ββΆ unit testing
β² β±
implementation
THE V-MODEL'S REAL INSIGHT: the acceptance test criteria come
from the REQUIREMENTS, not from the code. Writing the
acceptance tests during requirements analysis is what catches
untestable requirements β which is exactly the "test-case
generation" validation technique from the requirements topic.
WHERE THE EFFORT AND COST GO β with the numbers.
EFFORT DISTRIBUTION in a typical project:
testing accounts for 30β40% of total project effort, and
for safety-critical systems can exceed 50%.
THE COST OF FINDING A DEFECT AT EACH LEVEL β this is why the
levels are ordered as they are. Using the Boehm ratios from
the design topic, with a nominal 1 unit at requirements:
level found relative cost in a suite of 10,000
tests, time per run
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
unit test 20Γ seconds
integration test 30Γ a few minutes
system test 50Γ tens of minutes
acceptance test 75Γ hours to days
after release 100Γ plus reputation
WORKED β why the pyramid shape is economic, not aesthetic.
Suppose a suite with these per-test costs and run times:
unit 0.002 s per test
integration 0.4 s per test
end-to-end 8 s per test
A "PYRAMID" suite: 5,000 unit, 500 integration, 50 e2e
5000 Γ 0.002 = 10 s
500 Γ 0.4 = 200 s
50 Γ 8 = 400 s
βββββββ
610 s β 10.2 minutes
An "INVERTED PYRAMID" (ice-cream cone) with the same
total test count, 5,550, but weighted to e2e:
50 unit, 500 integration, 5,000 e2e
50 Γ 0.002 = 0.1 s
500 Γ 0.4 = 200 s
5000 Γ 8 = 40,000 s
βββββββββ
40,200 s β 11.2 HOURS
SAME NUMBER OF TESTS. 66Γ the wall-clock time. And the
inverted suite is also FLAKIER (e2e tests fail for
environmental reasons) and LESS PRECISE (a failure tells you
"checkout is broken", not which line). This arithmetic is
the entire argument for the test pyramid.
THE PRACTICAL CONSEQUENCE: a suite that takes 11 hours is run
nightly at best, so a developer learns about a break the next
morning β by which time they have moved on and the context is
gone. A 10-minute suite runs on every push. The FEEDBACK
LATENCY, not the test count, is what determines whether tests
actually prevent defects.
The two suite shapes are the number to remember from this topic: the same 5,550 tests take 10 minutes or 11 hours depending only on which level they live at. And the slow shape is also flakier and less precise about where the fault is β so it costs more and tells you less.
π Go further: two testing levels that postdate the classical list are worth knowing. Contract testing (met in the interface specification topic) fills the gap between integration and system testing for services owned by different teams: the consumer's expectations run against the provider's build. And testing in production β canary releases, feature flags, shadow traffic, synthetic monitoring β accepts that some properties (real user load, real data distributions, real third-party behaviour) genuinely cannot be observed anywhere else, and makes it deliberate and reversible rather than accidental. Search "canary release feature flags testing in production".
π‘ Exam angle: define testing (Myers), and state that a successful test finds an error β examiners like that inversion. Give Dijkstra's limit and explain why exhaustive testing is impossible. Distinguish error / fault / failure and verification / validation. Describe all four levels β unit, integration, system, acceptance β with who performs each and what each can and cannot find. For integration, compare top-down and bottom-up with the advantages and disadvantages of each and the roles of stubs and drivers. Distinguish alpha from beta testing, and draw the V-model.
Syllabus points
Unit, integration, system, component, acceptance testing
Create a free account to tick topics off, take notes as you read, watch the video lessons and get a day-by-day study plan built around your exam date.
Related topics in Testing, Cost Estimation, Quality & Configuration Management