0

I have found the following questions regarding statement coverage.

Minimum Test Required for Statement Coverage:

  1. Disc = 0
  2. Order-qty = 0
  3. Read Order-qty
  4. If Order-qty >=20 then
    1. Disc = 0.05
    2. If Order-qty >=100 then
      1. Disc =0.1
    3. End if
  5. End if

In my opinion, we need 2 statement coverage. But the correct answer is 1 statement based on many websites.

I don't understand why only one statement coverage is needed.

1
  • What statements do you think aren't covered if, for example, Order-qty is 100?
    – jonrsharpe
    Aug 24, 2023 at 9:38

1 Answer 1

0

The reason you only need one statement is in the initial conditions, specifically

Order-qty = 0

With an order quantity of 0 there is only one possible pass through the logic listed: the first if statement, Order-qty >=20 evaluates to false, making the next statement number 5, the End if.

Different starting conditions could potentially require different coverage, but for any value of Order-qty between 0 and 19 inclusive, only one statement is needed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.