Question: a) Compute the Cyclomatic complexity of the method. Full path coverage testing requires that every possible path through the code be tested at least once.

a) 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 below, how many test cases would be needed for full path coverage? Why might full path coverage be impossible to achieve for some programs?

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

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!