2.4.2 Program Testing
2.4.2 Program Testing
Page 1 of 7
Computer Science 9608 (Notes)
Chapter: 2.4 Software development
e.g.MyArray(63)
Real number starts with Expression expected Illegal expression Include the leading 0 e.g.
decimal point but '.' found
MyReal := 0.34;
e.g. MyReal := .34;
Page 2 of 7
Computer Science 9608 (Notes)
Chapter: 2.4 Software development
Page 3 of 7
Computer Science 9608 (Notes)
Chapter: 2.4 Software development
Jan_ms := MillisecsPerDay *
31;
writeln(Jan_ms);
readln;
end.
Page 4 of 7
Computer Science 9608 (Notes)
Chapter: 2.4 Software development
Some errors cannot be detected by the compiler and only become apparent at run time. For example,
errors which depend on the input from a user cannot be predicted by the compiler.
Page 5 of 7
Computer Science 9608 (Notes)
Chapter: 2.4 Software development
When you have removed all the syntax errors, compile-time errors and run-time errors you may think it is
time to heave a huge sigh of relief - but don't forget that there may still be logical errors lurking in your
program.
Out-by-one (or off-by-one) errors are very common, hence the emphasis on boundary testing in
computing courses. The cause of the error is often the operator used, as in the first example below.
Page 6 of 7
Computer Science 9608 (Notes)
Chapter: 2.4 Software development
Take frequent breaks; mistakes are more likely when you are tired.
If in doubt, check. Look at examples if you are unsure of the correct syntax. Read the checklists
above from time to time and be on the lookout for those mistakes.
Learn from your mistakes. Try to recognize the types of mistake you make most often and
concentrate on reducing those.
Do not rely on the compiler to find your mistakes; it will only find certain types of mistake.
Check the computer output carefully to make sure it is correct. Your tests should include normal,
boundary and erroneous data. See our sample test plan in the tutorial on testing.
U U
Include checks in the program itself, such as validating the input and intermediate results.
U U
Try your hand at spotting the errors in our selection of Programs to Debug. See how many of our
U U
Page 7 of 7