Unit Test Coverage Reports Quiz: Test Your Skills Quiz

  1. Understanding Code Coverage

    What is code coverage as reported by unit test coverage tools?

    1. The proportion of code lines executed during testing
    2. The percentage of code lines commented
    3. The number of commits that contain tests
    4. The ratio of test files to source files
    5. The amount of code deleted during a test run
  2. Interpreting Coverage Thresholds

    If a coverage report shows 85% line coverage and your minimum threshold is 90%, what does this imply?

    1. You need to write more tests to cover additional code
    2. All code branches have been fully tested
    3. The coverage is above the required threshold
    4. There are syntax errors in your tests
    5. Coverage tools need to be re-installed
  3. Analyzing Missed Lines

    Given the code snippet: if (user == null) { throw new Error('Invalid'); }, what does it mean if this line is marked as uncovered?

    1. The test suite never triggers a null 'user' value
    2. This line was commented out during testing
    3. The function is never called in the codebase
    4. Coverage tool cannot analyze conditional statements
    5. The code was not compiled
  4. Excluding Files from Coverage

    Which statement best describes the effect of excluding a file from coverage reporting?

    1. The file's lines will not impact overall coverage percentage
    2. Excluded files will be tested twice
    3. Coverage for excluded files is shown as 100%
    4. It will reduce the number of bugs in the file
    5. Coverage reports will auto-delete the file
  5. Branch vs. Line Coverage

    What is the main difference between branch coverage and line coverage in a coverage report?

    1. Branch coverage checks all possible paths; line coverage counts executed lines
    2. Branch coverage is slower to compute than line coverage
    3. Line coverage includes test file lines, branch does not
    4. Branch coverage is only used in Python, not JavaScript
    5. Line coverage requires manual analysis
  6. Improving Low Coverage

    After viewing your coverage report, you notice several untested functions. What should you do to improve your test coverage?

    1. Add new unit tests targeting the untested functions
    2. Delete the functions from the codebase
    3. Decrease the coverage threshold
    4. Turn off code coverage tools
    5. Commit untested code to main branch
  7. False Coverage Readings

    What could cause the coverage report to falsely indicate that code is covered?

    1. Tests execute lines but do not verify outcomes (assert no assertions)
    2. Coverage tools are run with debug mode off
    3. All code is written in one file
    4. Test failures are ignored during test runs
    5. Coverage files are stored in the wrong directory
  8. Reading HTML Coverage Reports

    When using a coverage tool that outputs HTML reports, which color typically indicates uncovered code?

    1. Red
    2. Blue
    3. Green
    4. Yellow
    5. Purple
  9. Coverage and Continuous Integration

    Why integrate code coverage checks into a continuous integration (CI) pipeline?

    1. To automatically enforce test coverage levels before merging code
    2. To increase compilation speed
    3. To reduce the test file size
    4. To generate additional test files automatically
    5. To convert JavaScript code to Python
  10. Interpreting Coverage Summary

    If your coverage summary shows functions: 90%, statements: 95%, and branches: 80%, what should you investigate further?

    1. Review branch coverage for untested conditional logic
    2. Stop writing additional tests since coverage is high
    3. Add comments to all functions
    4. Reduce the number of branches in your code
    5. Ignore the coverage report