0
0
Testing Fundamentalstesting~10 mins

Test coverage metrics in Testing Fundamentals - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to calculate the percentage of lines covered by tests.

Testing Fundamentals
coverage_percentage = (lines_covered / [1]) * 100
Drag options to blanks, or click blank then click option'
Atotal_tests
Btotal_lines
Clines_missed
Dlines_covered
Attempts:
3 left
💡 Hint
Common Mistakes
Using lines_covered as denominator
Using lines_missed instead of total lines
2fill in blank
medium

Complete the code to calculate branch coverage percentage.

Testing Fundamentals
branch_coverage = (covered_branches / [1]) * 100
Drag options to blanks, or click blank then click option'
Amissed_branches
Bcovered_branches
Ctotal_branches
Dtotal_lines
Attempts:
3 left
💡 Hint
Common Mistakes
Dividing by covered_branches
Using total_lines instead of total_branches
3fill in blank
hard

Fix the error in the code that calculates statement coverage.

Testing Fundamentals
statement_coverage = ([1] / total_statements) * 100
Drag options to blanks, or click blank then click option'
Astatements_covered
Btotal_statements
Ctotal_tests
Dstatements_missed
Attempts:
3 left
💡 Hint
Common Mistakes
Using statements_missed in numerator
Using total_statements in numerator
4fill in blank
hard

Fill both blanks to create a dictionary of coverage metrics for lines and branches.

Testing Fundamentals
coverage = {'lines': ([1] / total_lines) * 100, 'branches': ([2] / total_branches) * 100}
Drag options to blanks, or click blank then click option'
Alines_covered
Blines_missed
Cbranches_covered
Dbranches_missed
Attempts:
3 left
💡 Hint
Common Mistakes
Using missed counts instead of covered
Mixing lines and branches variables
5fill in blank
hard

Fill all three blanks to create a summary report dictionary with coverage percentages and total tests run.

Testing Fundamentals
report = {'line_cov': ([1] / total_lines) * 100, 'branch_cov': ([2] / total_branches) * 100, 'tests_run': [3]
Drag options to blanks, or click blank then click option'
Alines_covered
Bbranches_covered
Ctotal_tests
Dtests_passed
Attempts:
3 left
💡 Hint
Common Mistakes
Using tests_passed instead of total_tests
Using missed counts for coverage