Why is it important to be able to partition the test space into equivalence clas
ID: 3853771 • Letter: W
Question
Why is it important to be able to partition the test space into equivalence classes? For the following code fragment, describe 3 different test cases, and for each, describe the class of test cases it represents. Note: The below code might or might not have any issue(s).
public String printTriangleType (int x, y, z)
{
/* requires: The parameters are in ascending order (i.e. x <= y <= z)
effects: If x, y and z are the lengths of the sides of a triangle,
this function classifies the triangle using one of the three strings,
"scalene", "isosceles" or "equilateral". If x, y, and z do not form a
triangle, the empty string is returned. */
String r;
r="scalene";
if (x == y || y == z) { r="equilateral"; return r; }
if (x == z) { r="isosceles"; return r; }
if (x <= 0 || (x+y) <= z) { r=""; return r; }
return (r);
Explanation / Answer
Equivalence class test are needed to test function with all possibilities.
For this given the following are the equivalence test
For all the cases x,y,z represent the sides of the triangle.And Where blank is written it means triangle cannot be formed.
1) Weak Normal Equivalence Class
Test Case ID x y z Expected Output
WNE1 10 10 10 equilateral
WNE2 10 10 3 isocelec
WNE3 10 20 30 scalene
WNE4 40 10 20 blank
2) Weak Robust Equivalence Class
Test Case ID x y z Expected Output
WRE1 10 50 50 x value is wrong
WRE2 50 -10 50 y value is wrong
WRE3 50 50 -10 z value is wrong
WRE4 400 10 20 x value is out of range
4) Strong Robust Equivalence Class
Test Case ID x y z Expected Output
SRE1 -10 50 50 x value is wrong
WRE2 50 -10 50 y value is wrong
WRE3 50 50 -10 z value is wrong
WRE4 -10 -10 60 x and y value is out of range
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.