Computer Engineering is coming soon

We're still writing and reviewing the notes for every subject, and we'll open it when every subject is ready. Meanwhile you can practise aptitude, ask Aria about any subject, or see the branches that are ready.

Levels of testing: unit, integration, system and acceptance

Clear, exam-focused notes on the four levels of testing (unit, integration, system, acceptance) explaining definitions, purposes, common approaches, how they map to development phases, formulas/metrics, worked examples, common mistakes, and exam tips.

Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.

Why it matters

Software engineers use the four levels of testing—unit, integration, system, and acceptance—to find defects early, verify that parts work together, check the complete product against requirements, and confirm the product meets the user's needs before release. Knowing these levels helps you plan tests, assign responsibility, and justify when to stop testing.

Key ideas

Start with definitions (defined before using them):

  • Module — a separately compilable or deployable piece of code (function, class, package). Use this word when referring to the smallest unit you test.
  • Test case — a set of inputs, execution steps, preconditions, and expected results for verifying some behavior.
  • Test suite — a collection of test cases grouped for execution.

Now the four levels, each defined exactly as universities expect:

  • Unit testing — a level of testing where the smallest testable parts of software (modules) are tested in isolation to verify their correctness. Assumptions: modules have defined interfaces or can be isolated with stubs/drivers; code is stable enough to run locally. Typical performer: developer. Typical technique: white-box testing (but black-box unit tests also exist). Tools: JUnit, pytest, NUnit.

  • Integration testing — a level of testing where multiple modules are combined and tested as a group to find defects in interfaces and interactions. Assumptions: individual modules have passed unit tests; module interfaces are specified. Major approaches: big-bang (integrate all at once), incremental (top-down, bottom-up, or sandwich/hybrid). In incremental tests you use stubs (fake called module) and drivers (test harness that calls a not-yet-integrated module). Exact distinction: stubs replace lower-level modules; drivers replace higher-level callers.

  • System testing — a level of testing where a completely integrated system is tested against the system requirements specification. This is black-box testing of the complete system in a production-like environment. System testing includes functional and non-functional tests (performance, security, reliability, usability). Assumptions: integrated build is feature-complete; test environment approximates production.

  • Acceptance testing — a level of testing to determine whether the system meets user needs and is ready for delivery. Types: user acceptance testing (UAT) (end-users validate requirements), operational acceptance testing (OAT) (operations check deployability, backups), contract/alpha/beta acceptance. Acceptance tests are performed by or on behalf of the customer.

Key relationships and principles (state these exactly):

  • Law/Principle (testing cost curve): For typical software, the cost to fix a defect increases as you move from unit → integration → system → acceptance → production. Assumption: defect remediation requires more context, regression fixes, and more stakeholders the later it is found.

  • V-model mapping (exact statement): Each development phase has a corresponding test level: requirements ↔ acceptance testing; system design ↔ system testing; architectural design ↔ integration testing; detailed design / coding ↔ unit testing. Drawn as a V: left side downward are development phases, right side upward are corresponding tests; link matched levels with horizontal lines.

  • Objectives of each level (exact, exam style):

    • Unit: verify correctness of module logic and local error handling.
    • Integration: verify interfaces, data flow, and interaction between modules.
    • System: verify end-to-end functional and non-functional requirements.
    • Acceptance: validate against user needs and contractual criteria.

How to draw standard diagrams (describe exactly what to draw and label):

  • Testing pyramid: Draw a triangle (pyramid) with three layers. Base (largest) label “Unit tests (fast, many)”. Middle label “Integration tests (fewer)”. Top (small) label “System/Acceptance tests (slow, few)”. Optionally add arrows showing cost per test increasing upward.

  • V-model: Draw a large letter V. Left descending branch: Requirements → System design → Architecture → Module design/code at bottom. Right ascending branch: Unit tests (at bottom, linked to module design), Integration tests (linked to architecture), System tests (linked to system design), Acceptance tests (linked to requirements). Draw horizontal connectors between matching phases.

Practical notes and assumptions students must state in exam answers:

  • Who performs each level (developer, integration team/test team, QA/system testers, customer) and where (dev machine, integration lab, staging/prod-like environment, customer environment).
  • When to use stubs/drivers and why (incremental integration).
  • That test environments should be as production-like as practical; differences must be documented. Also state entry and exit criteria for each test level (entry: prerequisites such as code complete, unit tests passed, interfaces defined, test data and environment ready; exit: coverage targets met, critical/major defects resolved or deferred by agreement, acceptable defect leakage risk, and test report/review approved).

Formulas

Coverage = (tested items / total items) * 100% — Coverage percentage. Items could be modules, functions, or requirements. Unit: percent.

PassRate = (passed_tests / executed_tests) * 100% — Test execution pass rate. Unit: percent.

DRE = (defects_found_before_release / (defects_found_before_release + defects_found_after_release)) * 100% — Defect Removal Efficiency. Unit: percent. Use when measuring how effective pre-release testing was.

DDR = defects_found_during_level / total_defects_found * 100% — Defect detection rate for a test level. Unit: percent.

Note: These are metrics used across levels. Always state what counts as a defect in numerator and denominator when you apply them.

Worked examples

Example 1 — Numerical (DRE):

Problem: During testing you found 340 defects before release. After release, customers reported 60 defects traced to code faults. Compute DRE and interpret.

Steps:

  1. Formula: DRE = defects_found_before_release / (defects_found_before_release + defects_found_after_release) * 100%.
  2. Substitute: DRE = 340 / (340 + 60) * 100% = 340 / 400 * 100%.
  3. Calculation: 340 / 400 = 0.85 → 0.85 * 100% = 85%.

Answer: DRE = 85%. Interpretation: 85% of defects were found before release; remaining 15% escaped to production.

Example 2 — Tracing tests for a small system (algorithmic / procedural):

System: A simple calculator application with modules: A (UI), B (Parser), C (Arithmetic library with add/subtract/multiply/divide), D (Logging).

Show which tests you would write and in what order using incremental integration (bottom-up):

  1. Unit tests: developer writes unit tests for C (arithmetic) functions: add(x,y), divide(x,y) including division by zero; for B (parser) tokenization; for D (logging) that a log entry is created.
  2. Integration (bottom-up): start by integrating C modules into a mini-library and test calls from a driver that simulates B. Use drivers to call C if B isn't ready. Then integrate B with C and run tests for expression evaluation. Use a driver to simulate A (the higher-level caller) and, if D is not ready, use a stub to replace D (the called lower-level module) at this stage.
  3. System tests: integrate A, B, C, D into a full application. Run end-to-end tests: examples like "enter 2+3*4" and verify result and UI messages. Add non-functional tests (response time for 10,000 calculations).
  4. Acceptance tests (UAT): let representative users run typical workflows (financial calculator scenarios). Check contractual criteria (e.g., accuracy to 6 decimal places) and operational checks (backup of logs) for OAT.

Example 3 — Model exam answer (theory):

Question: "Compare top-down and bottom-up integration testing and give advantages of each."

Model answer (short, full marks): Define top-down and bottom-up (one sentence each). Explain that top-down integrates high-level modules first using stubs for lower modules; bottom-up integrates low-level modules first using drivers for higher modules. Advantages: top-down finds architectural/interface errors early and allows early prototype demonstration; bottom-up provides testable low-level utility correctness early and avoids many stubs. State assumptions: availability of top-level control flow or of test drivers. End with a brief note on hybrid/sandwich approach combining both.

Common mistakes

  • Omitting environment assumptions (students forget to say where tests run and that environments must be production-like for system/acceptance tests).
  • Thinking integration testing only checks data values; it primarily checks interfaces and interaction, not only values.
  • Using DRE without clarifying what counts as defects before/after release.
  • Drawing the testing pyramid upside down or labeling layers inconsistently.

For your exam

Question types you will see: definitions, short notes, compare-and-contrast (e.g., unit vs integration), diagrams (draw V-model or pyramid), derivations or justification of testing order, small numerical problems using DRE/coverage, and procedure/tracing questions (show test sequence for a small system).

What a full-marks answer includes:

  • Clear definitions (bold term or exact phrase), assumptions, and who performs the level.
  • A labeled diagram if asked (describe precisely what you draw and labels).
  • For comparisons: list at least two differences and two advantages each; include stubs/drivers if relevant.
  • For numerical: show formula, substitute numbers, do arithmetic step-by-step, give units (percent) and an interpretation in one sentence.
  • For procedural/tracing: list concrete test cases at each level and show ordering and rationale.

Quick check

  1. Which test level typically uses stubs to replace lower-level modules?
  2. Write the formula for pass rate as a percentage.
  3. Who normally performs user acceptance testing (UAT)?

Answers: 1. Top-down integration testing (stubs replace lower-level modules). 2. PassRate = (passed_tests / executed_tests) * 100%. 3. Representative end-users or customer's test team perform UAT.

Finished this topic? Mark it so your progress, study plan and readiness keep up.

Stuck on something here?