Levels of Testing Explained: Unit, Integration, System and Acceptance with a Worked Example

Follow one library-loan scenario from isolated functions to stakeholder approval, and learn how to classify each testing level by its boundary and evidence.

KnowledgeGate Team

Exam prep & CS education

Updated 30 Nov 20266 min read
Levels of Testing Explained: Unit, Integration, System and Acceptance with a Worked Example

The same library-loan behaviour can be checked through one function, cooperating modules, the complete application, or a librarian's acceptance rule. Calling every check "end-to-end testing" hides the test boundary and makes classification harder.

Member S17 is active and has 2 existing loans against a limit of 3. Copy B42 is available; issuing it on day 10 creates loan L900 for 14 days, due on day 24. Unit tests a small decision, integration tests connections, system tests the integrated product, and acceptance tests whether agreed needs are met.

Levels of testing by scope and purpose

Nested Unit, Integration, System, and Acceptance testing scopes for one library-loan example.

A level is defined by its test object and pass/fail evidence. Scope generally expands like this:

Level

Primary scope

Main question

Library example

Unit

One function or isolated component

Does this logic return the right result?

canBorrow(true, 2, 3) -> true

Integration

Cooperating components or interfaces

Do parts exchange and preserve data correctly?

LoanService writes L900 and updates B42

System

Complete integrated application

Does the product satisfy system requirements?

POST /api/loans returns the correct full-stack result

Acceptance

Agreed user or business need

Is the result acceptable for use or delivery?

The librarian's loan rule is satisfied

This order is conceptual, not a rigid calendar; levels can overlap and repeat. A level differs from a design approach (black-box or white-box), quality examined (functional, performance or security), and execution (manual or automated). Software Quality in Software Engineering covers that wider view. Levels identify boundary and evidence.

Nested scope diagram showing a library loan scenario: member S17 borrows copy B42, receives loan L900, and owes it on day 24.

Unit testing: prove the smallest decisions

Here the unit boundary contains two pure functions. canBorrow(active, currentLoans, maxLoans) evaluates active && currentLoans < maxLoans. For S17, true && 2 < 3 is true. At the limit, true && 3 < 3 is false; an inactive member also fails. calculateDueDay(issueDay, loanDays) gives 10 + 14 = 24.

Code
assert canBorrow(true, 2, 3) == true
assert canBorrow(true, 3, 3) == false
assert canBorrow(false, 2, 3) == false
assert calculateDueDay(10, 14) == 24

Direct inputs drive deterministic logic, with no database, HTTP route, queue or screen. Several calls may remain inside one component. Passing checks isolate rule defects, but do not prove that records load, storage or the workflow works.

Integration testing: verify components and state

Seed active S17, loans L701 and L702, available B42, maximum 3, and no L900. Call LoanService.issueLoan("S17", "B42", 10, 14) through real repositories and a test database. Record external notifications with an adapter.

MemberRepository returns active status and count 2; CatalogRepository returns available=true. The rules give true and 10 + 14 = 24. LoanRepository inserts {id:"L900", memberId:"S17", copyId:"B42", dueDay:24, status:"OPEN"}, the catalogue makes B42 unavailable, and the adapter records {type:"LoanIssued", loanId:"L900", memberId:"S17", copyId:"B42", dueDay:24} once.

Assert both sides: one L900 exists, S17 has 2 + 1 = 3 open loans, B42.available is false, and one event exists. Contracts and state transitions cross component boundaries, making this integration testing. If the insert fails, the transaction must leave B42.available=true and record zero events.

System testing: exercise the complete application

Start the deployed test application with that seed and use its public HTTP boundary, not LoanService:

http
POST /api/loans
Content-Type: application/json

{"memberId":"S17","copyId":"B42","issueDay":10,"loanDays":14}

The successful response follows from eligibility 2 < 3 and due day 10 + 14 = 24:

http
HTTP/1.1 201 Created

{"loanId":"L900","memberId":"S17","copyId":"B42","dueDay":24,"status":"OPEN"}

GET /api/members/S17/loans must show L701, L702 and L900; GET /api/copies/B42 must show available=false. Route validation, logic, repositories, transaction and serialization participate. A recording substitute may sit beyond the product boundary when a third-party provider is unavailable.

System tests also cover non-functional behaviour. Under a hypothetical requirement of a 95th-percentile response time no greater than 2 seconds for 500 concurrent lookups, exercising the deployed product is a system-level performance test.

Acceptance testing: judge an agreed need

Given active member S17 has 2 open loans, the allowed maximum is 3, and B42 is available; when a librarian issues B42 on day 10 under a 14-day rule; then loan L900 is confirmed, due day 24 is shown, S17 has 3 open loans, and B42 is unavailable for another issue.

The oracle has changed. Unit checks a predicate, integration checks shared state, system checks the complete response, and acceptance checks whether the agreed outcome is fit for use. System and acceptance tests may perform the same action, but their purpose and authority differ.

Users, product owners, operations teams, customers or authorised representatives may check acceptance. User, contractual and operational acceptance are possible contexts; the criterion, not a job title, defines the evidence.

Compare the four levels without common traps

Signal in the question

Best level

Why

One predicate with direct inputs

Unit

No collaborator is crossed

Service plus database adapter

Integration

An interface and stored state are checked

Complete HTTP-to-database workflow

System

The integrated product boundary is exercised

Librarian approves the agreed outcome

Acceptance

Stakeholder criteria decide readiness

Common traps:

  • Uses mocks, so it must be unit: doubles do not decide the level.

  • Uses a database, so it must be system: one service plus its repository can be integration.

  • Runs through the UI, so it must be acceptance: a UI-driven check can still be a system test.

  • Acceptance means defect-free: it shows agreed criteria are met, not that no defect exists.

  • System and acceptance need different scenarios: they may reuse one scenario for different purposes.

  • The four names are techniques: they are levels of scope and objective.

Unit -> Integration -> System -> Acceptance is the conventional scope sequence, not a universal schedule. Iterative teams may repeat all four. Ask: What is inside the boundary, and who or what supplies the pass/fail rule? Use that evidence, not tools, job titles or the word automated.

How exam-style questions test levels of testing

Classify each scenario by its boundary and pass/fail evidence before reading the answer:

  1. canBorrow(true, 3, 3) returns false: Unit. Direct inputs test one predicate.

  2. LoanService inserts L900 and updates B42 through repositories: Integration. Repository contracts and state are checked.

  3. POST /api/loans returns 201 and public reads show the new state: System. The whole product runs.

  4. A librarian confirms that S17 may take B42 and sees day 24 under the agreed rule: Acceptance. Stakeholder criteria supply the oracle.

A full application checked after its test database restarts is system testing because recovery is under test. An authorised team checking agreed issue-and-return workflows is acceptance testing because readiness supplies the oracle.

Use Levels of Testing MCQs: 12 Solved Questions on Unit, Integration, System and Acceptance Testing to practise definitions, order, stubs, coverage and acceptance criteria. Those questions test rapid classification; the library-loan example traces one outcome through four boundaries. For a broader route, use UGC NET Preparation Courses & Test Series and the NTA UGC NET Paper - 2 Test Series.

Levels of testing: the short version and next step

  • Unit: one decision or component.

  • Integration: connections and shared data.

  • System: the complete integrated product.

  • Acceptance: agreed user or business readiness.

The chain is S17, 2 of 3 loans, and B42 on day 10: unit gives due 24, integration writes L900, system returns 201, and acceptance confirms the rule.

Change only currentLoans from 2 to 3, keeping maxLoans=3 and B42.available=true. Predict the unit result, whether L900 remains absent, the response category and the acceptance outcome. All four levels should preserve the rejection. The scenario does not define a specific HTTP error status.

Continue with NTA-UGC-NET Paper - 2 for structured Software Engineering. Redraw the nested boundaries, place each S17/B42 assertion, then classify the four prompts without looking back.