Testing

Testing is essential if you want to have any faith that your programs work.

For each of the examples you wrote down in the Examples step, starting with the simplest,

  1. type it into the CodePad (just the expression itself, not the comments or the "expected answer"), and
  2. see whether it gives the answer you expected.
  3. If it's not what you expected, either you were expecting the wrong thing (possible, though unlikely) or there's a bug in your program. Figure out how the answer is wrong (not just that it's wrong) and how this wrong answer could have happened, fix it, and try again. When you fix a bug, be sure to re-examine the previously working examples to make sure they still work!

If you prefer, you can test a method by invoking it with the mouse and typing in the arguments. However, since you've already written down the method call in the Examples step, it's probably easier to just copy and paste that into the CodePad.

This is what I call "manual testing". It's OK if you only have a few test cases, and it's easy to see whether the answer is correct. But as things get more complicated, you'll have more and more test cases, and it makes sense to automate the testing process. We'll see in a few days how to do this.


Last modified: Fri Jan 30 11:42:39 EST 2009
Stephen Bloch / sbloch@adelphi.edu