GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Testing  >  Whitebox Testing
Go To First  |  Previous Question  |  Next Question 
 Whitebox Testing  |  Question 42 of 46    Print  
100% Path and Decision Coverage
How many test cases are needed to have 100% path coverage and decision coverage in the following code. if (conditionA)
{
c=c+1
}
if(conditionB)
d=d-1
else
e++

consider condition A and condition B are independent.



  
Total Answers and Comments: 4 Last Update: August 13, 2009     Asked by: shruti.girdhar 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
August 31, 2008 05:15:15   #1  
Valusa79 Member Since: August 2008   Contribution: 3    

RE: 100% Path and Decision Coverage

If these conditions A & B are independent. Assuming as these are not
interlinked (as c d and e are not affecting each other) you can simply write 4
tests as below:


1. Condition A true value

2. Condition A false value

3. Condition B true value

4. Condition B false value


If they are linked then you can test the below conditions:


1. Condition A true value Condition B true value

2. Condition A true value Condition B false value

3. Condition A false value Condition B true value

4. Condition A false value Condition B false value


If you are not convinced with these please provide more details.


Regards

Valusa


 
Is this answer useful? Yes | No
October 23, 2008 21:57:34   #2  
tagro82 Member Since: March 2006   Contribution: 23    

RE: 100% Path and Decision Coverage
Path Coverage is all path covered
So for Condition 1 as there is no else part so 1 TC
for condition 2 2 T.C .

Decision Coverage requires 4 T.C

 
Is this answer useful? Yes | No
July 06, 2009 00:27:51   #3  
bhavikt21 Member Since: July 2009   Contribution: 1    

RE: 100% Path and Decision Coverage
There are 4 different paths
so Path coverage: 4
2 conditions so 4 decisions
but it can be reduced to 2
Condition 1 Condition2
T F
F T
Actually it also depends on what is the given condition.


Worst case is 4 best case is 2.

 
Is this answer useful? Yes | No
August 13, 2009 03:18:01   #4  
anjali.puretrainings Member Since: August 2009   Contribution: 1    

RE: 100% Path and Decision Coverage
Path coverage 2
Decision coverage 4

 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape