Recall & Review
beginner
What is a coverage threshold in software testing?
A coverage threshold is a set minimum percentage of code that must be tested to consider the test suite sufficient. It helps ensure enough code is covered by tests.
Click to reveal answer
beginner
Why use coverage thresholds in JUnit testing?
Coverage thresholds help maintain code quality by preventing code changes without enough tests. They alert developers if test coverage drops below a safe level.
Click to reveal answer
intermediate
How can you enforce coverage thresholds in a JUnit project?
You can use tools like JaCoCo with your build system (Maven or Gradle) to set coverage thresholds. The build fails if coverage is below the set percentage.
Click to reveal answer
intermediate
What types of coverage can thresholds be set for?
Thresholds can be set for line coverage, branch coverage, method coverage, and class coverage to ensure different aspects of code are tested.Click to reveal answer
beginner
Example: What happens if line coverage threshold is set to 80% but actual coverage is 75%?
The test run or build will fail, signaling that the tests do not cover enough lines of code and more tests are needed.
Click to reveal answer
What does a coverage threshold do in testing?
✗ Incorrect
Coverage thresholds set a minimum percentage of code that must be tested to pass.
Which tool is commonly used with JUnit to enforce coverage thresholds?
✗ Incorrect
JaCoCo is a popular tool to measure and enforce code coverage in Java projects.
If your coverage threshold is 90% and actual coverage is 85%, what happens?
✗ Incorrect
The build fails because coverage is below the required threshold.
Which coverage type measures how many decision branches are tested?
✗ Incorrect
Branch coverage measures how many possible paths (branches) in the code are tested.
Why is setting coverage thresholds helpful?
✗ Incorrect
Coverage thresholds help ensure tests cover enough code to reduce bugs.
Explain what coverage thresholds are and how they help maintain test quality in JUnit projects.
Think about how coverage thresholds prevent untested code from slipping through.
You got /4 concepts.
Describe how you would configure a coverage threshold for line coverage in a JUnit project using JaCoCo.
Consider the build configuration file and threshold settings.
You got /4 concepts.