A few notes from Jennifer Campbell & Paul Gries' outstanding Coursera MOOC Crafting Quality Code
- examples
- type contract
- header
- description
- body
- test
When choosing test cases, consider the following factors:
- For collections (strings, lists, tuples, dictionaries) test with:
- empty collection
- a collection with 1 item
- smallest interesting case
- collection with several items
Consider your situation:
For example:
- vowels/non-vowels
- even/odd
- positive/negative
- empty/full
If a function behaves differently for a value near a particular threshold (i.e. an if statement checking when a value is 3; 3 is a threshold), test at the that threshold.
If a function behaves differently when the values are in a different order, identify and test each of those orders.