Test coverage measures how much of the software's code or features are tested by the test cases. It helps find untested parts.
Click to reveal answer
beginner
Name two common types of test coverage metrics.
Two common types are code coverage (which checks how much code is tested) and requirement coverage (which checks how many requirements are tested).
Click to reveal answer
intermediate
What does statement coverage measure?
Statement coverage measures the percentage of executable statements in the code that have been run by tests.
Click to reveal answer
intermediate
Why is 100% test coverage not always enough?
Because tests might run code but not check if it works correctly. Also, some bugs happen in combinations or unexpected inputs not covered by tests.
Click to reveal answer
intermediate
What is branch coverage and why is it important?
Branch coverage measures if every possible branch (like if-else branches) in the code has been tested. It helps find missing tests for decision points.
Click to reveal answer
Which test coverage metric measures the percentage of code lines executed by tests?
ARequirement coverage
BStatement coverage
CBranch coverage
DPath coverage
✗ Incorrect
Statement coverage counts how many code statements are run during testing.
What does requirement coverage focus on?
ATesting all functions
BTesting all code branches
CTesting all user requirements
DTesting all variables
✗ Incorrect
Requirement coverage checks if all specified user needs are tested.
Why might 100% code coverage still miss bugs?
ABecause code coverage only measures requirements
BBecause code coverage tools are inaccurate
CBecause tests run too slowly
DBecause tests might not check outputs or logic correctness
✗ Incorrect
Running code doesn't guarantee the test checks if the result is correct.
Branch coverage ensures testing of:
AAll decision paths like if-else
BAll user stories
CAll code statements
DAll database queries
✗ Incorrect
Branch coverage tests every possible decision path in the code.
Which metric helps identify untested requirements?
ARequirement coverage
BCode coverage
CBranch coverage
DStatement coverage
✗ Incorrect
Requirement coverage tracks which requirements have test cases.
Explain what test coverage metrics are and why they matter in software testing.
Think about how much of the software is tested.
You got /3 concepts.
Describe the difference between statement coverage and branch coverage.
One counts lines, the other counts decision points.
You got /3 concepts.
Practice
(1/5)
1. What does test coverage metric measure in software testing?
easy
A. The time taken to run all tests
B. The number of bugs found during testing
C. The percentage of code or features tested compared to total code or features
D. The number of testers involved in the project
Solution
Step 1: Understand the purpose of test coverage
Test coverage measures how much of the software is tested, usually as a percentage.
Step 2: Identify what is compared in coverage
It compares tested code or features against the total code or features available.
Final Answer:
The percentage of code or features tested compared to total code or features -> Option C
Quick Check:
Test coverage = tested items / total items [OK]
Hint: Coverage shows tested parts over total parts [OK]
Common Mistakes:
Confusing coverage with number of bugs
Thinking coverage measures test duration
Assuming coverage counts testers
2. Which of the following is the correct formula for calculating test coverage percentage?
easy
A. (Number of tested code lines / Total code lines) * 100
B. (Total tests / Number of testers) * 100
C. (Number of bugs found / Total tests) * 100
D. (Number of tests run / Total number of tests) * 100
Solution
Step 1: Identify what test coverage measures
Test coverage measures how much code is tested, so it relates to tested code lines over total code lines.
Step 2: Match formula to coverage concept
The formula is (tested code lines / total code lines) * 100 to get percentage coverage.
Final Answer:
(Number of tested code lines / Total code lines) * 100 -> Option A
Hint: Coverage = tested code lines divided by total lines [OK]
Common Mistakes:
Using number of tests run instead of code lines
Confusing bugs found with coverage
Dividing by number of testers
3. Consider a software module with 200 lines of code. If 150 lines are executed during testing, what is the test coverage percentage?
medium
A. 85%
B. 75%
C. 65%
D. 70%
Solution
Step 1: Identify total and tested lines
Total lines = 200, tested lines = 150.
Step 2: Calculate coverage percentage
Coverage = (150 / 200) * 100 = 0.75 * 100 = 75%.
Final Answer:
75% -> Option B
Quick Check:
150/200 = 0.75 = 75% [OK]
Hint: Divide tested lines by total lines, multiply by 100 [OK]
Common Mistakes:
Dividing total lines by tested lines
Forgetting to multiply by 100
Mixing up tested and total lines
4. A tester reports 90% test coverage, but some critical code paths are not tested. What is the likely issue?
medium
A. Coverage metric only measures quantity, not quality of tests
B. Tester calculated coverage incorrectly
C. Test coverage always guarantees all paths tested
D. The software has no untested code
Solution
Step 1: Understand what coverage measures
Coverage measures how much code is tested but not which specific paths or quality of tests.
Step 2: Identify why critical paths might be missed
High coverage can still miss important paths if tests do not cover all scenarios.
Final Answer:
Coverage metric only measures quantity, not quality of tests -> Option A
Quick Check:
Coverage % ≠ test quality [OK]
Hint: Coverage shows quantity, not test quality [OK]
Common Mistakes:
Assuming coverage means all paths tested
Blaming tester calculation without proof
Ignoring untested critical paths
5. You have a project with 3 modules: Module A (100 lines, 80 tested), Module B (150 lines, 120 tested), Module C (50 lines, 40 tested). What is the overall test coverage percentage?
hard
A. 70%
B. 75%
C. 77.5%
D. 80%
Solution
Step 1: Calculate total lines and total tested lines