- Test every line of code, but more importantly, test every path through the code.
Let's say you have the following pseudocode:\nif (x == z)\n // do something with foo\nendif\n\nif (y == q)\n // do something else with foo\nendif\n\n// do another thing with foo\n
Then you should have 4 tests for this piece of code: x != z and y != q, x = z and y != q, x != z and y = q, x = z and y = q. - Test all boundary conditions. If you have some code like "if (x > 5)", then pass it x = 4, x = 5, and x = 6.
- Test for null objects. Pass nulls into places and see what happens.