Question: Write a set of test cases – specific set of data – to properly test a relatively Simple program. Create a set of test data for the program - data the program must handle correctly to be considered a successful program. Here’s a description of the program:
“The program reads three integer values from an input dialog. The three values represent the lengths of the sides of a triangle. The program displays a message that states whether the triangle is scalene, isosceles, or equilateral”.
Code: The function triangle takes three integer parameters that are interpreted as the lengths of the sides of a triangle. It returns whether the triangle is equilateral (three lengths equal), isosceles (two lengths equal), scalene (no lengths equal), or invalid (impossible lengths).
Evaluate your test cases: Evaluate your set of test cases by using it to answer the following questions. Give yourself one point for each “YES” answer.
- Do you have a test case that represents a valid scalene triangle? (Note that test case such as 1,2,3 and 2,5,10 do not warrant a “YES” answer because there does not exist a triangle having these dimensions.)
- Do you have a test case that represents a valid equilateral triangle?
- Do you have a test case that represents a valid isosceles triangle? (Note that a test case representing 2,2,4 would not count because it is not a valid triangle.)
- Do you have at least three test cases that represent valid isosceles triangles such that you have tried all three permutations of two equal sides (such as, 3,3,4; 3,4,3; and 4,3,3)?
- 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 integers greater than zero such that the sum of two of the numbers is equal to the third? (i.e., if the program said that 1,2,3 represents a scalene triangle, it would contain a bug.)
- Do you have at least three test cases in category 7 such that you have tried all three permutations where the length of one side is equal to the sum of the lengths of the other two sides (for example, 1,2,3;1,3,2; and 3,1,2)?
- Do you have a test case with three integers greater than zero such that the sum of two of the numbers is less than the third (such as 1,2,4 or 12,15,30)?
- Do you have at least three test cases in category 9 such that you have tried all three permutations (for example, 1,2,4; 1,4,2; 4,1,2)?
- Do you have a test case in which all sides are zero?
- Do you have at least one test case specifying non-integer values (such as 2.5, 3.5, 5.5)?
- Do you have at least one test case specifying the wrong number of values (two rather than three integers, for example)?
Of course, a set of test cases that satisfies these conditions does not guarantee that all possible errors would be found, but since questions 1 through 13 represent errors that actually have occurred in different versions of this program, an adequate test of this program should expose at least these scores.
Possible Solution:
Tester Action and Input Data Expected Outcome
Erroneous Input Partition
One test case with each a,b,c a non number An error message
One test case with each a,b, or c a real number An error message
Scalene Triangle Partition
2,3,4 Scalene
maxint-2, maxint-1, maxint Scalene
(maxint = largest legal integer)
1,2,3 An error message
5,3,2 An error message
1,2,4 or 1,4,2 or 4,1,2 An error message
-2,3,4 An error message
0,1,2 An error message
maxint-1, maxint, maxint+1 An error message
Isosceles Triangle Partition
2,2,1 Isosceles
9,5,5 Isosceles
maxint, maxint-1, maxint Isosceles
1,2,1 An error message
2,5,2 An error message
3,1,1 An error message
2,-2,1 An error message
2,2,0 An error message
maxint, maxint+1, maxint An error message
Equilateral Triangle Partition
1,1,1 Equilateral
maxint, maxint, maxint Equilateral
maxint+1, maxint+1, maxint+1 An error message
1,1,-1 An error message
0,0,0 An error message
User Interface Tests
Overflow each input buffer for a,b,c An error message
Try a leading space for a,b,c An error message
Leave a,b,c blank An error message
Try a trailing space for a,b,c An error message
Comments