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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started