Next: Vocabulary
Up: Testing Software
Previous: Testing Software
As an entrance into the area of software testing and to get a first
impression of the difficulties met in this field, a small
exercise will be given here (taken from
[Myers79]):
Assume there is a program which reads three integers. Those three
values will be interpreted as the longitudes of the legs of a triangle.
The program will determine if this triangle is equilateral, isosceles,
or none of these and output its result.
Now please take a sheet of paper and write down a set of inputs for
this program which you think would be a good test for it.
Please check your answers. Here is a suggestion for a good set of inputs.
Feel free to use it as a checklist:
- Do you have a test case that represents a valid scalene
triangle
? - Do you have a test case for a valid equilateral triangle?
- Do you have a test case for a valid isosceles
triangle
? - Do you have at least three test cases that represent valid
isosceles triangles such that you have tried the three permutations of
two equal sides (for instance (2, 2, 3), (2, 3, 2), and (3, 2, 2))?
- Do you have a test case in which one side has a zero value?
- Do you have a test case in which one side has a negative value?
- Do you have a test case with three positive integers so that the
sum of two is equal to the third
? - Have you tried all permutations of category seven?
- Do you have a test case with three positive integers so that the
sum of two is less than the third?
- Have you tried all permutations of category nine?
- Do you have a test case in which all sides are zero?
- Do you have at least one test case with noninteger values?
- Do you have one test case with the wrong number of values?
- Last, but not least, did you specify the expected output for each
test case?
There is no doubt that this list is not able to detect all
bugs which might be in such a program, but since all
fourteen points represent faults which have been found in various
versions, your set of inputs should be able to detect those. Do not be
frustrated, if you did not get a lot of points from this list, because
even professional programmers get in the average only one half of them.
And this example was designed to demonstrate how difficult it is to
develop a good test for a simple program. Now just image how much worse
it must be to do such a test for a huge program.
Next: Vocabulary
Up: Testing Software
Previous: Testing Software
Ingo Melzer
Mon Aug 5 15:12:01 MET DST 1996