How do I come up with test cases? Test case checklist
Designing test cases can be tricky. It's important to think about all the possible ways your students might approach this problem.
In addition, the ordering of your test cases can be crucial - think about ordering them from the simplest example or most common mistake, to the most complex.
For most problems, you be able to easily come up with at least 5 test cases!
Example test case scenarios
Here are some example test cases that we typically use on problems:
- A test case that is capitalisation-insensitive and/or punctuation-insensitive
- A test case for each of your example(s) in the problem description
- A test case that is similar to but not exactly the same as those in the problem description
- A test case that is similar to but not exactly the same as those in the problem description, but make it hidden
- A test case for any edge cases! For example:
- Very large or long input (eg. a long string, a long line of text, many lines of text, etc)
- Very small or short input (eg. a single character, a single line, etc)
- No input!
- Any other edge cases?
- (When testing string methods) A test case that checks that the expected string is in the right place and only in the right place (eg. “Simon says” appearing at the beginning but not inside a line of text)
- One or two test cases that are “black box” hidden test cases. Typically, these should be similar to (but not exactly the same as) test cases that the student has already passed.