Computer Science I / Testing Small Programs
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
  1. Ten typical inputs to a sum function. How many distinct code paths do they exercise?
  2. 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.

Read the lesson: Testing Small Programs →

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