0
0
Testing Fundamentalstesting~20 mins

Test coverage metrics in Testing Fundamentals - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Test Coverage Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding Statement Coverage

Which statement best describes statement coverage in software testing?

AIt measures the percentage of functions that have been called during testing.
BIt measures the percentage of all possible input combinations tested.
CIt measures the percentage of executable statements in the code that have been executed by the tests.
DIt measures the percentage of user interface elements tested.
Attempts:
2 left
💡 Hint

Think about how many lines of code your tests actually run.

Predict Output
intermediate
2:00remaining
Calculating Branch Coverage Output

Given the following code snippet and test cases, what is the branch coverage percentage?

def check_number(x):
    if x > 0:
        return 'Positive'
    else:
        return 'Non-positive'

Test cases run: check_number(5)

A100%
B50%
C0%
D75%
Attempts:
2 left
💡 Hint

Branch coverage counts how many decision branches are tested.

assertion
advanced
2:00remaining
Assertion for Path Coverage

Which assertion correctly verifies that all paths in the following function have been tested?

def classify(num):
    if num > 0:
        if num % 2 == 0:
            return 'Positive Even'
        else:
            return 'Positive Odd'
    else:
        return 'Non-positive'
Aassert path_coverage == 100
Bassert path_coverage >= 50
Cassert path_coverage == 75
Dassert path_coverage == 0
Attempts:
2 left
💡 Hint

Count all unique paths through the nested if statements.

🔧 Debug
advanced
2:00remaining
Debugging Coverage Report Mismatch

A test suite reports 80% statement coverage but 100% branch coverage. What is the most likely cause?

ATests cover all decision points but miss some simple statements outside decisions.
BThe coverage tool is broken and reports wrong values.
CBranches are counted incorrectly, inflating branch coverage.
DSome statements are not executable but counted in statement coverage.
Attempts:
2 left
💡 Hint

Think about how branches and statements differ in coverage.

framework
expert
2:00remaining
Integrating Coverage Metrics in CI Pipeline

Which approach best ensures that test coverage metrics are enforced automatically in a Continuous Integration (CI) pipeline?

ARun coverage tools locally only and ignore coverage in CI.
BManually check coverage reports after each build and notify the team if low.
CUse coverage tools only for documentation, not for build decisions.
DConfigure the CI to run tests and fail the build if coverage falls below a set threshold.
Attempts:
2 left
💡 Hint

Automation is key in CI pipelines.