Recall & Review
beginner
What is statement coverage in software testing?
Statement coverage measures the percentage of executable statements in the code that have been run by the test cases. It helps ensure that every line of code is tested at least once.
Click to reveal answer
beginner
Why is statement coverage important?
It helps find parts of the code that are never executed during testing, which might hide bugs. Testing all statements increases confidence that the code works as expected.
Click to reveal answer
beginner
How do you calculate statement coverage?
Statement coverage = (Number of statements executed by tests / Total number of statements) × 100%. For example, if 80 out of 100 statements run, coverage is 80%.
Click to reveal answer
intermediate
Does 100% statement coverage guarantee bug-free software?
No. It means every statement ran, but it doesn't check if all conditions or paths work correctly. Other coverage types like branch coverage are needed for deeper testing.
Click to reveal answer
beginner
Give a simple example of statement coverage.
If a function has 5 lines and your test runs 4 of them, statement coverage is 80%. For example, if an if-statement's else part never runs, those lines are not covered.
Click to reveal answer
What does statement coverage measure?
✗ Incorrect
Statement coverage measures how many code statements are executed during testing.
If a program has 50 statements and tests run 40, what is the statement coverage?
✗ Incorrect
Coverage = (40/50)*100 = 80%.
Does 100% statement coverage mean all bugs are found?
✗ Incorrect
100% statement coverage means all lines ran, but some bugs can still hide in logic or conditions.
Which coverage type is deeper than statement coverage?
✗ Incorrect
Branch coverage tests all possible paths, including if-else branches, which is deeper than statement coverage.
What happens if some code statements are never executed during testing?
✗ Incorrect
Unexecuted code might hide bugs because it was never tested.
Explain statement coverage and why it is useful in software testing.
Think about how running each line of code helps find bugs.
You got /3 concepts.
Describe the limitations of statement coverage and what other coverage types can complement it.
Consider what happens if only some paths run but not others.
You got /3 concepts.