-1

I'm interested and studying statement and decision coverage.

What type of problem will be found with 100% decision coverage that would be missed by 100% statement coverage?
        A.  A problem that occurs within a loop
        B.  A problem that occurs in an IF with an ELSE
        C.  A problem that occurs in an IF without an ELSE
        D.  A problem that occurs outside a loop

I got this sample question and I selected the correct answer as B.

Because 100% statement coverage ensures that every individual statement in the code has been executed at least once. However, it doesn't guarantee that all decision branches and all possible true and false outcomes of conditions have been tested.

But my friend said that the correct answer should be C.

Can anyone explain the correct answer?

1 Answer 1

0

The Correct Answer is B.

Here are the explanations for the four given choices:

A. A problem that occurs within a loop:

Statement coverage would generally involve executing each statement at least once, which may include statements within a loop. However, it doesn't guarantee coverage of all decision points within the loop.

B. A problem that occurs in an IF with an ELSE:

Decision coverage, in contrast to statement coverage, ensures that both the true and false branches of decision points (like an IF-ELSE statement) are executed at least once. So, a problem within an IF-ELSE construct could be detected with 100% decision coverage that might be missed with 100% statement coverage.

C. A problem that occurs in an IF without an ELSE:

Similar to option B, decision coverage ensures that both branches of a decision point are covered. Therefore, a problem within an IF statement without an ELSE could also be identified with 100% decision coverage.

D. A problem that occurs outside a loop:

Statement coverage, if achieved at 100%, ensures that every statement in the code is executed at least once, including those outside of loops.

So, the key here is that 100% decision coverage ensures that both branches of decision points are executed, whereas 100% statement coverage only guarantees that each statement is executed at least once. Hence, option B is correct because it highlights a scenario where decision coverage is more comprehensive than statement coverage.

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.