Practice question · Multiple choice
A test suite that passes on typical inputs can miss bugs that a handful of edge cases would catch immediately. Why are the edges so much more productive to test than the middle?
Hints
- Ten typical inputs to a sum function. How many distinct code paths do they exercise?
- Now try the empty list. What does that exercise?
Show the answer
B. Because bugs cluster where behaviour changes, while typical inputs share one path.
Why
Ten typical inputs usually walk the same route, so the tenth tells you almost nothing the first did not, where each edge probes somewhere different: empty tests the zero-iteration path, one element tests initialisation, the maximum tests overflow. Property-based tools generate inputs systematically and find edges humans do not think of, which says something about how far intuition gets you.
Practise Testing Small Programs
The app has 5 more questions on this lesson, and keeps your place in the course. Computer Science I is free to start.
More questions on Testing Small Programs
- A program that passes one hundred typical-case tests is guaranteed to have no bugs.
- A function is meant to accept a whole number of items. Sort each test input by its kind.
- Order the steps of writing and running one test case.
- A test asserts that a function returns something, and passes even when the function returns the wrong answer.…
- A function takes a list of numbers. Select every input that is an edge case worth testing.