Thursday 11 August 2016

Week 3 Assignment Solution

This post 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.

Note: Please post solution related queries in the course forum only.
  1. The principal aim of carrying out code coverage analysis is to evaluate the quality of:
  1. Product
  2. Test cases
  3. Coding
  4. Design


  1. If branch coverage has been achieved on a unit under test, which one of the following types of coverage is implicitly  implied?
  1. Path coverage
  2. Multiple condition coverage
  3. Statement coverage
  4. Data flow coverage


  1. Which one of the following attributes of a program can be inferred from its Cyclomatic complexity?
  1. Computational complexity
  2. Lines of code (LoC)
  3. Executable code size
  4. Understandability


  1. Which one of the following statements about Cyclomatic complexity metric of a program is FALSE?
  1. It is a measure of the testing difficulty of the program.
  2. It is a measure of understanding difficulty of the program.
  3. It is a measure of the linearly independent paths in the program
  4. It is a measure of the size of the program


  1. 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?
  1. N1+N2
  2. N1+N2+1
  3. N1+N2-1
  4. N1*N2

  • Explanation: It is a standard result. The proof is beyond the scope of the course.

  1. 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);
}
  1. 2
  2. 3
  3. 4
  4. 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.

CFG.png




  1. If branch coverage has been achieved on a unit under test, which of the following is coverage is implicitly implied?
  1. Path coverage
  2. Multiple condition coverage
  3. Statement coverage
  4. Data flow coverage

  1. 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;
  1. 1
  2. 2
  3. 3
  4. 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.


  1. 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;
  1. 1
  2. 2
  3. 3
  4. 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.


  1. 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;
  1. 2
  2. 4
  3. 6
  4. 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.
Share:

Contact Me

Name

Email *

Message *

Popular Posts