ISEB-SWTINT1 · Question #11
You have designed test cases to provide 100% statement and 100% decision coverage for the following fragment of code. If width > length then Biggest_dimension = wifth Else Biggest_dimenstion =…
The correct answer is C. None, existing test cases can be used. Option C is correct because the three Print statements are sequential, unconditional code - they execute on every single test run regardless of the if/else branch taken. Since your existing test cases already run the full code block (hitting both branches), those print…
Question
Options
- AOne more test case will be required for 100 % decision coverage.
- BTwo more test cases will be required for 100 % statement coverage, one of which will be used to
- CNone, existing test cases can be used.
- DOne more test case will be required for 100% statement coverage.
How the community answered
(28 responses)- A4% (1)
- B11% (3)
- C82% (23)
- D4% (1)
Explanation
Option C is correct because the three Print statements are sequential, unconditional code - they execute on every single test run regardless of the if/else branch taken. Since your existing test cases already run the full code block (hitting both branches), those print statements are automatically executed, meaning both statement coverage and decision coverage remain at 100% with zero additional tests.
Why A is wrong: No new decision (branch point) was introduced - print statements have no condition to evaluate true or false, so decision coverage is unaffected.
Why B is wrong: Statement coverage doesn't require new tests either, because the print statements run unconditionally in every existing test case - they were already being "covered" the moment any test ran.
Why D is wrong: Same reasoning as B - statement coverage is already satisfied; adding sequential print statements to the end of a code block doesn't create any uncovered statements when existing tests already execute the full block.
Memory tip: Ask yourself, "Does this new code only execute under a specific condition?" If the answer is no (like print statements at the end of a block), your existing tests already cover it. Only new if/else, loops, or conditional logic can demand additional test cases.
Topics
Community Discussion
No community discussion yet for this question.