Question

In: Computer Science

SE 4367, Software Testing Homework #10, Control Flow Coverage For the following program P written in...

SE 4367, Software Testing

Homework #10, Control Flow Coverage

For the following program P written in pseudo-code, given the test set T: T = {t1 = <4, 2>, t2 = <90, 0>, t3 = <56, 1>}

  1. What is the statement coverage for T?
  2. What is the block coverage for T?
  3. What is the decision coverage for T?
  4. What is the condition coverage for T?
  5. What is the condition/decision coverage for T?

Program P

  1. integer X, Y, Z;
  2. input (X, Y);
  3. // Check for legal inputs.

4)   if ((X≥0 AND X≤100)AND(Y>0 AND Y<4))

5)   {

6)        Z = -1;

7)       if (X < 60)

8)       {

9)             Z = 0;

10)            if (X > 80 AND Y == 1) 11)                 Z = 59;

12)            Z = Z + 3;

13)      }

14)      else // !(X<60)

15)      {

16)           Z = 61;

17)           if (Y == 0)

18)               Z = 99;

19)           else

20)               Z = 62;

21)           Z = Z + 1;

22)      } // end else !(X<60)

  1. output (X,Y,Z);
  2. } // end if legal inputs
  3. else
  4. output (“Error *** Invalid input.”);
  5. output (“Program ends.”);
  6. end;

Solutions

Expert Solution

a- Statement Coverage is a white box testing technique in which all the executable statements in the source code are executed at least once. It is used for calculation of the number of statements in source code which have been executed. The main purpose of Statement Coverage is to cover all the possible paths, lines and statements in source code.

So, Statement coverage = (no of executed statements/total no of statement)*100.

So, For t1=<4,2>,

statement coverage = (16/28)*100=57.14%

So, For t2=<90,0>,

statement coverage = (8/28)*100=28.57%

So, For t1=<56,1>,

statement coverage = (16/28)*100=57.14%

b-Block coverage testing is done to ensure that blocks of code aren't left untested by failing to test all paths of a conditional statement.

So, For t1=<4,2>,

block coverage = (2/7)*100=28.57%

So, For t1=<90,0>,

block coverage = (1/7)*100=14.28%

So, For t1=<56,1>,

block coverage = (2/7)*100=28.57%

c-Decision Coverage is a white box testing technique which reports the true or false outcomes of each boolean expression of the source code. The goal of decision coverage testing is to cover and validate all the accessible source code by checking and ensuring that each branch of every possible decision point is executed at least once.

decision coverage=(no of decision outcome excercised/total no of decision outcomes).

So, For t1=<4,2>,

decision coverage = (2/7)*100=28.57%

So, For t1=<90,0>,

decision coverage = (1/7)*100=14.28%

So, For t1=<56,1>,

decision coverage = (2/7)*100=28.57%

d-In condition coverage, one of the Boolean expression have been evaluated to both TRUE and FALSE.

So, in t1=<4,2> , 1st if condition is evaluated true followed by the nested if block inside the same. Rest all if and else will be evaluted false as they don't satisfy the required condtion.

Now, in t2=<90,0>, only the outer else condtion is evaluated true while all the rest conditions are false.

Again in t3=<56,1>, st if condition is evaluated true followed by the nested if block inside the same. Rest all if and else will be evaluted false as they don't satisfy the required condtion.

e- explained above in c& d.


Related Solutions

Can this be written out please, for my Bath Uni homework. Cash Flow Analysis. You are...
Can this be written out please, for my Bath Uni homework. Cash Flow Analysis. You are considering a 5-year investment project which is expected to cost $1, 000, 000. In each year, you have decided that there are 3 possible states of the economy: good, average, and poor. In each individual year there is a 35% chance of the economy being good and a 15% chance of it being poor. You forecast the following net cash flows for the project:...
1. A software program is able to recognize a hand written letter about 63% of the...
1. A software program is able to recognize a hand written letter about 63% of the time. (a) What is the probability that it takes less than 4 letters before the program recognizes one? (b) What is the expected number of letters shown to the program before it recognizes one? (c) If we show the program 20 letters, what is the probability that it recognizes exactly 12 of them? (d) If we show the program 20 letters, what is the...
The Baily Corporation has developed a specialized software program that improves inventory control capability. The following...
The Baily Corporation has developed a specialized software program that improves inventory control capability. The following table/information provides the necessary data to evaluate: Quarter Forecast (units) Regular Time Overtime Sub-Contract 1 500 400 80 100 2 750 400 80 100 3 900 800 160 100 4 450 400 80 100 Initial Inventory = 200 units Regular Time Cost = $2.50/unit Overtime Cost = $1.00/extra per unit Subcontracting Cost = $4.00/unit Carrying Cost = $.50/unit Back-Order Cost = $.75/unit The company...
Homework 1 Python basics and flow control Given August 26th – Due September 8th In this...
Homework 1 Python basics and flow control Given August 26th – Due September 8th In this assignment you have to develop a security program. Inside a while loop you will ask several security questions. Be creative! When all of them are answered correctly a piece of secret information will be printed and the program will be finished. In your program: - use at least 1 time each of the following functions: print(), input(), len(), str(), int(), float() and randint(). -...
Complete the following Module 2 Written Homework Assignment for this module by the stated due date...
Complete the following Module 2 Written Homework Assignment for this module by the stated due date on the Schedule. Please submit in the Module 2 Written Homework Assignment folder as a .doc, .docx, .pdf or .rtf file. Instructions Complete the following questions in the form of short essays. Each question is worth 6 points. Be sure to cite your references as needed. Type all responses following each question on this assignment page and submit to the folder. All-you-can-eat restaurants allow...
Control Flow 1. What is the difference between 10 / 3 and 10 // 3? 2....
Control Flow 1. What is the difference between 10 / 3 and 10 // 3? 2. What is the result of 10 ** 3? 3. Given (x = 1), what will be the value of after we run (x += 2)? 4. How can we round a number? 5. What is the result of float(1)? 6. What is the result of bool(“False”)? 7. What is the result of 10 == “10”? 8. What is the result of “bag” > “apple”?...
Flow control is one of the main building blocks that determines how a program should run....
Flow control is one of the main building blocks that determines how a program should run. Ghana Cocoa Growing Company wishes to compare the impart of two newly acquired fertilizers on cocoa. They will do this by applying the same quantity of the two fertilizers on two similar but different cocoa plant under the same conditions (humidity, sunlight, soil moisture etc.). They will then choose the fertilizer whose crop produces the best harvest (highest quantity per square feet). As a...
Part II. Researchers are testing the effects of a new diet program on n = 10...
Part II. Researchers are testing the effects of a new diet program on n = 10 healthy participants. One topic that researchers are interested in are overall attitudes towards dieting. They are interested in knowing if the new diet program will change the participants attitudes towards dieting. Participants rated their attitude about diets before and after the diet program. Participant Before Diet After Diet 1 2 3 4 5 6 7 8 9 10           15 10 7 18 5...
1) Bob gets the following homework grades: 2, 2, 2, 2, 2, 10, 10, 10, 10,...
1) Bob gets the following homework grades: 2, 2, 2, 2, 2, 10, 10, 10, 10, 10 Tom gets the following homework grades: 7, 7, 7, 7, 7, 7, 7, 7, 7, 7 Pat gets the following homework grades: 1, 1, 8, 8, 8, 8, 8, 8, 10, 10 Find the mean homework grade for each student, find the median homework grade for each student, and estimate the standard deviation for each student. You should not find the actual standard...
Given the following program below answer the following questions. 1.Draw a program flow graph for the...
Given the following program below answer the following questions. 1.Draw a program flow graph for the binsearch() function 2. Find the Define and Usage node, du-paths and dc-paths for all the variables int binsearch(int x,int v[],int n) { int low,high,mid; low=0; high=n-1; while(low<high) { mid = ( low + high ) / 2; if( x < v[mid]) high = mid - 1; else if ( x > v[mid]) low = mid + 1; else return mid; } return -1; }
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT