Practice question · Multiple choice
Two modules each work perfectly and fail when combined. What kind of defect does that suggest, and why do unit tests miss it?
Hints
- Unit tests replace the other module with a mock. Ask what the mock is built from.
- One returns null for 'not found'; the other expects an empty list. Who is wrong?
Show the answer
B. An interface mismatch, which only an integrated test reveals
Why
Unit tests check each module against your belief about the other, encoded in a mock, so a mistaken belief is baked into both sides and neither test fails. It is precisely what integration testing exists for, and why contract or consumer-driven tests are used to pin the boundary down explicitly.
Practise Modular Decomposition and Reuse
The app has 6 more questions on this lesson, and keeps your place in the course. Computer Science I is free to start.
More questions on Modular Decomposition and Reuse
- Match each modular-design term to what it describes.
- SavingsAccount extends Account and overrides applyMonthly(). A variable declared as Account is holding a…
- A date-handling module is being designed. Sort each item by whether it should be public or private.
- The same block of validation logic has been copy-pasted into six files. Select every consequence the lesson…
- Order the steps of factoring duplicated logic into one reusable unit.