dimanche 23 avril 2017

What is branch coverage?

I am preparing myself for ISTQB exam and i came across this question.

7. For the code fragment given below, which answer correctly represents
minimum tests
required for statement and branch coverage respectively?
Discount rate=1;
Fare = 1000;
If ((person == “senior citizen”) and (“travel month = January”))
Bonuspoints = 100+Bonuspoints
If (class==”first”)
discountRate = .5;
Fare = fare * discountRate;
a. Statement Coverage = 1, Branch Coverage = 2
b. Statement Coverage = 2, Branch Coverage = 2
c. Statement Coverage = 1, Branch Coverage = 3
d. Statement Coverage = 2, Branch Coverage = 4 

Answer is A

But my answer is C the reason is flowchart i draw for it given below.

  1. Straight forward from start to end

  2. One false for 1st 'if'

  3. second false for 2nd 'if'

Flow chart

My question is:

  1. Should we draw an edge 'explicitly' for 'false' condition, if it is not given in question itself.
  2. How branch coverage is 3 here ?

Aucun commentaire:

Enregistrer un commentaire