Search code examples
conditional-statementscode-coverage

ISTQB question: Statement Coverage and Decision Coverage


I interesting and studying about 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 select 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 all possible true and false outcomes of conditions have been tested.

But My friend said that correct answer should be C.

Can anyone explain me the correct answer.


Solution

  • for example, if you have the following code snippet

    input age;
    if age>65
    display "you are a senior"
    

    From a statement perspective, you have three statements that going through will cover 100%. However, a decision/branch coverage is not covered—what happens if the age is <65? This is not covered even though statement is 100%.

    • decision coverage 1: age > 65
    • decision coverage 2: age < 65

    Testing these decision cases will cover the tests and will catch that scenario, generating 100% decision coverage.