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.
- The principal aim of carrying out code coverage analysis is to evaluate the quality of:
- Product
- Test cases
- Coding
- Design
- If branch coverage has been achieved on a unit under test, which one of the following types of coverage is implicitly implied?
- Path coverage
- Multiple condition coverage
- Statement coverage
- Data flow coverage
- Which one of the following attributes of a program can be inferred from its Cyclomatic complexity?
- Computational complexity
- Lines of code (LoC)
- Executable code size
- Understandability
- Which one of the following statements about Cyclomatic complexity metric of a program is FALSE?
- It is a measure of the testing difficulty of the program.
- It is a measure of understanding difficulty of the program.
- It is a measure of the linearly independent paths in the program
- It is a measure of the size of the program
- 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?
- N1+N2
- N1+N2+1
- N1+N2-1
- N1*N2
- Explanation: It is a standard result. The proof is beyond the scope of the course.
- 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);
}
- 2
- 3
- 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.
- If branch coverage has been achieved on a unit under test, which of the following is coverage is implicitly implied?
- Path coverage
- Multiple condition coverage
- Statement coverage
- Data flow coverage
- 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
- 2
- 3
- 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.
- 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
- 2
- 3
- 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.
- 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;
- 2
- 4
- 6
- 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.