0
0
Testing Fundamentalstesting~5 mins

Statement coverage in Testing Fundamentals - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
ANumber of test cases written
BNumber of bugs found in the code
CPercentage of code statements executed by tests
DTime taken to run all tests
If a program has 50 statements and tests run 40, what is the statement coverage?
A80%
B50%
C40%
D90%
Does 100% statement coverage mean all bugs are found?
AYes, all bugs are found
BOnly syntax bugs are found
COnly performance bugs are found
DNo, some bugs may still exist
Which coverage type is deeper than statement coverage?
ASyntax coverage
BBranch coverage
CCode style coverage
DTest case coverage
What happens if some code statements are never executed during testing?
AThose parts might contain hidden bugs
BThe code is guaranteed bug-free
CTests are faster
DCode is optimized automatically
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.