Testing
-
You should have a
list of example inputs and the expected output from your programs.
- This is
called a Test Plan.
- Each time you change your program, you should
test it using your test plan to make sure that your program
still works for all the test cases. It is quite common to make a change
and unexpectedly break something else. A good test plan will help you spot
this all-too-common mistake.
-
Testing does not guarantee a program is perfect, but it increases the
confidence that the program is correct.
- If your solution is well designed and well written, bugs can be fixed
with less effort and more correctly than a solution that is not as well
designed or well written.
- Testing does not just occur at the end. A good programmer tests as they
go.
This is often referred to as
Unit Testing.
- The person who wrote the code knows how it is "supposed" to work, so is biased.
In a complex, real-world situation, the programmer should not be responsible for the final testing of their own code.
- Usually a separate group of testers is responsible for the final testing.
This is often referred to as
System Test.
Make sure that if your program does not give the expected output that you
fix the one that is incorrect.
You can't just make program and your test plan match!