Idea 19of 23Builds onFind the bug, fix the lineGreater than, less than, equal to
Test the number on the edge
Which input finds a bug in a condition?
Today you'll discover
- why to test the edge number
- how > can miss 'or more'
- how to fix it
Think firstGroups of 10 or more pay $4 each
A group of 10 should pay $40. What does this code charge them?
Decide first, then press Next. Find the test that sits right on the edge.
Group price code: IF number > 10 THEN MULTIPLY BY 4 ELSE MULTIPLY BY 6. A table of tests: 12 people give $48, goal $48; 8 people give $48, goal $48; 10 people give $60, goal $40, the row ringed. The fixed code, IF number > 9, gives $40 for 10 and meets every goal. The last step asks how to fix a museum rule written as age > 65.
See the whole ideathe big idea and the key word, in one place
The big idea
Test the number on the edge of a condition: that is where a > or < bug hides.
Good test casesFor '10 or more', test a number below the edge (8), the edge itself (10) and a number above it (12).
Easy to get wrongCode can pass every test you try and still have a bug. Always test the edge number.
Key word
- test case
- an input, and the output it should give, used to check that code works
Ready to use it?
- Choose test cases that check the edge of a condition.