1

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

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 ?

marked as duplicate by Bharat Mane, IAmMilinPatel, mutt, NarendraC, Michael Durrant Apr 25 '17 at 22:34

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.