Recall & Review
beginner
What is line coverage in software testing?
Line coverage measures the percentage of code lines executed by tests. It shows which lines ran during testing.
Click to reveal answer
beginner
Define branch coverage.
Branch coverage checks if each possible path (true/false) in decision points like if-else statements is tested.
Click to reveal answer
intermediate
Why is branch coverage important beyond line coverage?
Branch coverage ensures all decision outcomes are tested, catching bugs missed by line coverage alone.
Click to reveal answer
intermediate
Example: What does 100% line coverage but 50% branch coverage mean?
All lines ran, but only half of decision paths (branches) were tested. Some conditions may be untested.
Click to reveal answer
beginner
How can JUnit tests help improve branch coverage?
By writing tests that cover all if-else outcomes and loops, JUnit tests increase branch coverage.
Click to reveal answer
What does line coverage measure?
✗ Incorrect
Line coverage shows how many lines of code ran during testing.
Branch coverage ensures testing of:
✗ Incorrect
Branch coverage tests all possible paths in decision points.
If a test covers every line but misses some branches, coverage is:
✗ Incorrect
All lines ran but some decision paths were not tested.
Which JUnit feature helps check coverage?
✗ Incorrect
JUnit combined with coverage tools measures line and branch coverage.
Branch coverage is especially useful for testing:
✗ Incorrect
Branch coverage ensures all loop and condition paths are tested.
Explain the difference between line coverage and branch coverage.
Think about code lines vs decision points.
You got /3 concepts.
How can you write JUnit tests to improve branch coverage?
Consider all possible paths in your code.
You got /3 concepts.