Sie sind auf Seite 1von 3

Week 3 Assignment Solution 

 
This  document  provides  solution  to  the  third  assignment  of  the  online  course 
Software  Testing  offered  by  MHRD.  The  answers   to  each  questions are marked in 
red​. Explanation for numerical problems are given below each problem. 
  
1. ​The principal aim of carrying out code coverage analysis is to evaluate the quality of: 
a) Product 
b) Test cases 
c) Coding 
d) Design 
 
2. If  branch coverage has been achieved on a unit under test, which one of the following types of 
coverage is implicitly  implied? 
a) Path coverage 
b) Multiple condition coverage 
c) Statement coverage 
d) Data flow coverage 
 
3. Which  one  of  the  following  attributes  of  a  program  can  be  inferred  from  its   Cyclomatic 
complexity? 
a) Computational complexity 
b) Lines of code (LoC) 
c) Executable code size 
d) Understandability 
 
4. Which  one  of  the  following  statements  about  Cyclomatic   complexity  metric of  a  program  is 
FALSE? 
a) It is a measure of the testing difficulty of the program. 
b) It is a measure of understanding difficulty of the program. 
c) It is a measure of the linearly independent paths in the program 
d) It is a measure of the size of the program 
 
5. If two code segments have Cyclomatic complexities of N1 and N2 respectively, what will be 
the Cyclomatic complexity of the juxtaposition of the two code segments? 
a) N1+N2 
b) N1+N2+1 
c) N1+N2­1 
d) N1*N2 
Explanation: It is a standard result. The proof is beyond the scope of the course. 
6. What would be the Cyclomatic complexity of the following program? 
int find-maximum(int i,int j, int k){
int max;
if(i>j) then
if(i>k) then max=i;
else max=k;
else if(j>k) max=j
else max=k;
return(max);
}  
a) 2 
b) 3 
c) 4 
d) 5 
 
Explanation:  Using the  control  flow graph shown below, we compute Cyclomatic complexity for the 
given program using the formula E ­ N + 2 as (11 ­ 9 + 2) i.e. 4. 
 

 
 
 
7. If  branch coverage  has  been achieved  on  a  unit under test, which of the following is coverage 
is implicitly implied? 
a) Path coverage 
b) Multiple condition coverage 
c) Statement coverage 
d) Data flow coverage 
 
8. At  least how  many  test  cases  are  required  to  achieve  MC/DC coverage  of the  following  code 
segment: 
If((a>5) and (b<100) and (c>50)) x=x+1;
a) 1 
b) 2 
c) 3 
d) 4 
 
Explanation:  The  number  of  test  cases  can  be  found  as N +  1, where  N  represents the number of 
basic conditions. Here N = 3, so the number of test cases are 4. 
 
9. At  least  how  many  test  cases  are  required  to  achieve  condition/decision  coverage  of  the 
following code segment: 
If((a>5) and (b<100) and (c>50)) x=x+1;
a) 1 
b) 2 
c) 3 
d) 4 
 
Explanation:  The  two  test  cases   (a  =  6,  b  =  99,  c  =  49)  and  (a  =  4,  b  = 101,  c =  49)  are  enough  to  
achieve condition/decision coverage. 
 
10. At  least  how  many  test  cases  are  required  to  achieve  multiple   condition  coverage  of  the  
following code segment: 
If((a>5) and (b<100) and (c>50)) x=x+1;
a) 2 
b) 4 
c) 6 
d) 8 
 
Explanation:  The  number  of test cases required can be easily found by the formula 2 ^ n. Here n = 3, 
so the number of test cases required is 8. 

Das könnte Ihnen auch gefallen