Lesson 2 · Unit 01
Choosing cases
Edges, boundaries and inputs that must be rejected
What you practise
- Happy path, edges (empty, one, many, boundaries, duplicates, negative), error cases
- Equivalence classes
- The bug is usually at the boundary
Try a question from this lesson
Pick one
The spec says a score of 90 or more is an A. Which single test input reveals the bug?
def grade(score):
if score > 90:
return "A"
if score > 80:
return "B"
return "C"function grade(score) {
if (score > 90) return "A";
if (score > 80) return "B";
return "C";
}function grade(score: number): string {
if (score > 90) return "A";
if (score > 80) return "B";
return "C";
}Hint
Three of these inputs sit comfortably inside a grade. One sits exactly on a line.
Correct answer
90
Why
95, 85 and 50 all get the right grade. Only 90 lands on the wrong side of >. Bugs gather at boundaries, so that is where tests should aim.
The idea
Concept cards are short on purpose. In the app they appear between questions, after you have met the idea.
Concept
Classes and boundaries
Inputs that the code treats the same way form a class. One test per class is enough: a second one from the same class finds nothing new.
Then test each boundary between classes, on both sides. That is where > gets written for >=.
score 0 .... 79 | 80 .. 89 | 90 .. 100
grade C | B | A
tests 50 79 | 80 89 | 90 9510 more exercises in the app
- 2× type the answer
- 4× multiple choice
- 1× fill the blanks
- 1× true or false
- 1× order the lines
- 1× match the pairs
Bitpath is an iOS app in development. Join the waitlist and you get one email when it is ready to try.