background image
<< Debugger - Tips on debugging | Part II - Enhancing Your Tests >>
Debugger - Designing and testing with debugging in mind
<< Debugger - Tips on debugging | Part II - Enhancing Your Tests >>
182
User's Guide
7 U
SING
THE
D
EBUGGER
Tips on debugging
Designing and testing with debugging in mind
Here are some suggestions for designing and testing a script that will
facilitate debugging it later:
·
Plan for debugging (and robustness) when you're designing the script, by
having your functions check for valid input and output, and inform you
in some way if problems occur.
·
Test each function as you write it, by building it into a small script that
calls the function with test arguments and performs some operation that
lets you know it works. Or use the debugger to step through the execution
of each function individually after you have coded all (or part) of the
script.
·
Test each routine with the full range of valid data values, including the
highest and lowest valid values. This is a good way to find errors in
control loops.
·
Test each routine with invalid values; it should reject them without
crashing.
·
Test each routine with null (empty) values. Depending on the purpose of
the script, it might be useful if a reasonable default value were provided
when input is incomplete.