18C. Testing

Testing needs to be extensive. It is not enough to try one or two inputs. Try a variety of inputs, from small to moderate to large. Put on your testing hat. Do your best to expose errors.

Among others, try inputs that are, in some sense, extreme. For example, if the input is a positive integer, try the smallest positive integer, 1. It is a good idea to try 2 and 3 as well. If there is a largest allowed input, try that. Mistakes in software often show up for inputs that are at or near the boundary of acceptable inputs.


Regression testing

Experts use an idea called regression testing. Instead of doing tests by hand, you write a script that performs tests automatically. You run the script often, at least after every nontrivial modification. When a test is found to work, it is not removed from the script. Each time you run the script, it runs all of the tests that have ever been done. That way, if your fix of one error breaks something else, you find out about it. Tests are only removed when they test a feature that has been removed.


Automatic tests for this course

For this course, each programming assignment has a test script that is provided for you. Use it.

It is not enough just to run the test script. Look at the results. Check whether they are correct. Most of the submissions that I get do not work, either due to inadequate testing or to lack of time or effort from the student. Resolve to be among those whose submissions work correctly.