Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

a) Why is it important to be able to partition the test space into equivalence c

ID: 3854140 • Letter: A

Question

a) 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);

}

b) Compute the Cyclomatic complexity of the method. Full path coverage testing requires that every possible path through the code be tested at least once. For the code fragment above, how many test cases would be needed for full path coverage? Why might full path coverage be impossible to achieve for some programs?

c) Statement coverage testing requires that all statements in the program executed at least once. Provide a test set which has a complete statement coverage. What kinds of error might this testing miss?

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

3) 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

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote