---
title: "Why unit tests are not enough"
subject: "Software Engineering"
chapter: 8
key: "semester_5/software_engineering:unit-test-not-enough"
source: https://www.bctengineer.com/q/semester_5/software_engineering/unit-test-not-enough
site: BCT Engineering
---

# Why unit tests are not enough

Software Engineering · Chapter 8: Software Testing and cost Estimation

- Asked in: year not given, 8 marks
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_5/software_engineering/unit-test-not-enough
- Whole chapter: https://www.bctengineer.com/md/semester_5/software_engineering/chapter-8

## Question

Why unit test is not enough in system with multiple interacting units? What other tests are required?

## Short answer

Unit testing verifies each unit in isolation using stubs and drivers, so it misses interface errors, real-data behavior, and emergent system properties. Systems with interacting units also need integration, regression, system, performance, security, recovery, release, and acceptance testing.

## Answer

**Unit testing** checks each unit (function, method or class) separately, usually with **stubs** and **drivers** standing in for the units it talks to. It shows that each unit works on its own, but in a system with many interacting units most serious faults lie in the **interactions**, which unit tests do not exercise.

#### Why unit testing is not enough

1. **Interface errors are not found.** Sommerville lists the interface types where faults occur:
   - *Parameter interfaces*: data passed between functions
   - *Shared memory interfaces*: blocks of memory shared by units
   - *Procedural interfaces*: a sub-system offering a set of procedures
   - *Message passing interfaces*: units requesting services by messages

   The common interface errors are:
   - **Interface misuse**: wrong type, order or number of parameters.
   - **Interface misunderstanding**: the caller makes wrong assumptions about the called unit, e.g. calling a binary search with an unsorted array.
   - **Timing errors**: producer and consumer run at different speeds, so stale data is read (in real-time and shared-memory systems).
2. **Stubs and drivers are not the real units.** A stub returns simple fixed values, so behaviour with real data is not tested.
3. **Data can be lost or changed across an interface**, and global data structures shared by units can be corrupted by one unit and break another.
4. **Combined functions may not work.** Sub-functions that are each correct may not produce the required main function when combined.
5. **Small errors add up.** Rounding errors that are acceptable in one unit can be magnified across units.
6. **Emergent and non-functional properties** (performance, security, reliability, usability) appear only when the whole system runs.
7. **Environment problems**: databases, networks, operating systems and hardware are not used in unit tests.

**Example:** in an online shop, the cart unit computes the total in paisa and passes it to the payment unit, which expects rupees. Both units pass their unit tests, but the customer is charged 100 times too much. Only integration testing finds this.

#### Other tests required

| Test | Purpose |
|---|---|
| Integration testing | Combine units (top-down, bottom-up, sandwich) and test their interfaces |
| Regression testing | Re-run tests after each change or integration step |
| System testing | Test the whole system against requirements |
| Performance/stress testing | Check response time and behaviour beyond the normal load |
| Security and recovery testing | Check protection against attack and recovery after failure |
| Release testing | Independent black-box test of the version to be delivered |
| Acceptance testing (alpha, beta) | Users confirm the system meets their needs |

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. Why is unit testing alone not enough for a system of many interacting units?
   A. Units cannot be tested separately
   B. Most serious faults lie in the interactions between units, which unit tests do not exercise
   C. Unit tests only find syntax errors
   D. Unit tests are always black-box
   Answer: B. Unit tests check units in isolation with stubs and drivers, so interface and interaction faults remain undetected. (Key point: Faults lie in interactions)

2. Calling a binary search routine with an unsorted array is an example of which interface error?
   A. Interface misuse
   B. Timing error
   C. Interface misunderstanding
   D. Parameter overflow
   Answer: C. The caller made a wrong assumption about the called unit's behaviour, which is interface misunderstanding. (Key point: Interface errors)

3. Why do stubs make unit testing incomplete?
   A. Stubs are slower than real units
   B. Stubs return simple fixed values, so behaviour with real data is not tested
   C. Stubs delete test data
   D. Stubs test only non-functional properties
   Answer: B. A stub is not the real unit, so real data and behaviour across the interface are not exercised. (Key point: Stubs and drivers limitation)

4. In the shop example, the cart gives the total in paisa but payment expects rupees, and the customer is charged 100 times too much. Which test finds this?
   A. Unit testing of the cart
   B. Unit testing of payment
   C. Integration testing
   D. Syntax checking
   Answer: C. Both units pass alone; only testing their interface by integration testing reveals the mismatch. (Key point: Paisa vs rupees example)

## Related in Software Engineering

- [Test cases for a quadratic equation program](https://www.bctengineer.com/question.md?key=semester_5%2Fsoftware_engineering%3Aquadratic-test-cases) — Software Engineering, chapter 8

## Related in other subjects

- [Unit hydrograph and UH for multiple storms](https://www.bctengineer.com/question.md?key=semester_5%2Fengineering_hydrology%3Auh-define-multiple-storm) — Engineering Hydrology, chapter 5, asked 2×
- [Tensile tests; split test advantage; h/d ratio](https://www.bctengineer.com/question.md?key=semester_5%2Fconcrete_technology_and_masonry_structure%3Atensile-tests-split-advantage-hd) — Concrete Technology and Masonry Structure, chapter 5
- [Per unit circuit of three-generator system, 30 MVA base](https://www.bctengineer.com/question.md?key=semester_4%2Fpower_system_analysis_i%3Apu-circuit-30mva-g1-g2-g3) — Power System Analysis I, chapter 3
- [Per unit system and its advantages](https://www.bctengineer.com/question.md?key=semester_4%2Fpower_system_analysis_i%3Aper-unit-system-advantages) — Power System Analysis I, chapter 3, asked 3×
