Coverage Calculation

Before we start understanding coverage calculation using different techniques, I would like to ask you to be really patient to read through the complete post. I tell you this because this particular post is going to be really lengthier post of posts that I have posted so far. :)

In my previous post I have covered about "Statement, Decision and Path Coverage", Hence I am going to skip them here if you have not taken look yet you can refer here.

As part of TTA course we will explore few more coverage testing techniques. So in this post we are going to talk about:

  • Condition Coverage ( K2)
  • Decision Condition Coverage (K3/K4)
  • Modified Condition/ Decision Coverage (K3/K4)
  • Multiple Condition Coverage (K3/K4)

Condition Coverage: 

The basic concept is that, when a decision is made by a complex expression that eventually evaluates to TRUE/FALSE, we want to make sure each atomic condition in the decision should be test for true/false. Condition Coverage is also called as "Branch Condition Coverage".

Example of Condition coverage looks like:

IF( cond_A)&(cond_B)&(cond_C) then....

A
B
C
Result
TC1
T
T
F
F
TC2
F
F
T
F

Condition coverage is not stronger than decision coverage because 100% condition does not imply 100% decision coverage. From the table you see that we have covered each atomic condition both ways but with that we have only tested false case for the whole decision.

Decision Condition Coverage:

The concept is that we need to achieve condition level coverage where each condition is tested both ways, TRUE and FALSE, and we also need to make sure that we achieve decision coverage by ensuring that the overall predicate be tested both ways, TRUE and FALSE.

Full decision condition coverage guarantees condition, decision and statement coverage and thereby is stronger than all three.This coverage technique is also called as "Condition decision coverage".

Example of Decision condition coverage looks like:

IF( cond_A)&(cond_B)&(cond_C) then....

A
B
C
Result
TC1
T
T
T
T
TC2
F
F
F
F


Multiple Condition Coverage:

The concept is to test every possible combination of atomic conditions in a decision. This one is truly exhaustive testing. The number of possible test cases is equal to 2^n where n is the number of atomic condition. This coverage technique is also called as "Branch condition combination coverage".

Example of Multiple condition coverage looks like:

IF( cond_A)&(cond_B)&(cond_C) then....

A
B
C
Result
TC1
T
T
T
T
TC2
T
T
F
F
TC3
T
F
T
F
TC4
T
F
F
F
TC5
F
T
T
F
TC6
F
T
F
F
TC7
F
F
T
F
TC8
F
F
F
F


Modified Condition/Decision Coverage ( MCDC):

Like decision/ condition coverage, MC/DC requires that each atomic condition be tested both ways and that decision coverage must be satisfied. It then adds one more factor: 
Each condition must affect the outcome decision independently while the other atomic conditions are held fixed.

MC/DC coverage may not be useful to all testers. It will likely be most useful to those who are testing mission or safety-critical software. This coverage technique is also called as "Condition determining coverage testing

In this coverage technique, we always find determinant in every atomic condition like shown below:

A or B -> true if either one is true
    0 -> true because of A, so A is determinant 
0      1 -> true because of B, so B is determinant
0      0 -> false because of A and B,  so both are determinant

A and B -> false if either one is false
1      0 -> false because of B, so B is determinant 
    1 -> false because of A, so A is determinant
     1 -> true because of A and B,  so both are determinant

Example of Modified decision/condition coverage looks like:

IF( cond_A)&(cond_B)&(cond_C) then....

A
B
C
Result
TC1
T
T
T
T
TC2
F
T
T
F
TC3
T
F
T
F
TC4
T
T
F
F
You must be confused to know how table above has only 4 test cases and how did we arrive at the magic number 4 in this case! I am going to explain that in a while.

Short answer to know how did we arrive at number 4 is:
Total number of test cases for MCDC =  total number of atomic conditions + 1
                                                             = 3+ 1 = 4

Ok, now elaborated answer to the same question:
We have to simple this "( cond_A)&(cond_B)&(cond_C)" predicate in order to apply MCDC how do we do that ? By substitution method!

( cond_A) = A
(cond_B) = B
(cond_C) = C
( cond_A)&(cond_B) = A&B 
 A&B = D  so now predicate looks like D & C so applying formula mentioned above:

D and C                                                     
1      0                                                      
     1         
     1 
 
going back one step now apply formula for A&B looks like below So, now substitute values of A & B in  place of value D.

A and B                    A and B and C
1      0                        1         1        0 
     1                        0         1        1
     1                        1         0        1
                                  1         1        1   
I am going to explain a bit more on how did i arrive at last table with values, as i said we are going to substitute values of A and B in place of D. 
Step1: First value of D is 1 and is not determinant so you can just fill in 1 and 1 for both A and B.
Step 2: Second value of D is 0 and is determinant and value of C is 1 which is not determinant. So just keep value 1 for C and for D lets fill it with by making one of the values of A and B as determinant at each time. 
Step 3: Fourth line, no we are not missing third line! as i said we filled in both line 2 and 3 in step 2. you can see value of D is 1 and is determinant so you have to fill in value 1 and 1 for A and B and making it both determinant.

Let us consider a sample question and solve it to get more idea about this coverage technique.

Q. For the statement "Result = A and(B or C)", describes test cases using all the following structure-based test design techniques:
  1. Condition testing
  2. Modified Condition Decision testing
  3. Multiple condition testing

Answer: 

1. Condition testing - both atomic conditions should be once true and once false.


A
B
C
Result
TC1
T
T
T
T
TC2
F
T
T
F
2. Modified Condition/Decision Coverage - applying formula.
Substitute D = B or C in given predicate and after substitution it is A and D

A and D         
1         0  -> 0      
0         1 ->  0
       1 ->  1

B or C
1       0 -> 1
0       1 -> 1
0       0 -> 0

Substitute values of B or C to D

A  and B or C
1         0       0
0         1       1
       1       0
1         0       1

3. Multiple Condition coverage: Apply Rule of thumb 2^ n  = 2^3 conditions = 8 test cases


A
B
C
Result
TC1
T
T
T
T
TC2
T
T
F
F
TC3
T
F
T
F
TC4
T
F
F
F
TC5
F
T
T
F
TC6
F
T
F
F
TC7
F
F
T
F
TC8
F
F
F
F

Comments

  1. Share great information about your blog , Blog really helpful for us . We read your blog , share most useful information in blog . Thanks for share your blog here . Mycotoxins testing

    ReplyDelete
  2. Coverage Calculation >>>>> Download Now

    >>>>> Download Full

    Coverage Calculation >>>>> Download LINK

    >>>>> Download Now

    Coverage Calculation >>>>> Download Full

    >>>>> Download LINK xh

    ReplyDelete

Post a Comment

Please leave your comments here