0
0
JUnittesting~5 mins

Coverage thresholds in JUnit - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
ARemoves tests that fail
BAutomatically fixes uncovered code
CSets a minimum code coverage percentage required
DIncreases code complexity
Which tool is commonly used with JUnit to enforce coverage thresholds?
AMockito
BSelenium
CJUnitPerf
DJaCoCo
If your coverage threshold is 90% and actual coverage is 85%, what happens?
ABuild fails
BBuild passes
CTests are skipped
DCoverage is ignored
Which coverage type measures how many decision branches are tested?
ALine coverage
BBranch coverage
CMethod coverage
DClass coverage
Why is setting coverage thresholds helpful?
AEnsures tests cover enough code to catch bugs
BGuarantees no bugs in code
CMakes tests run faster
DRemoves the need for manual testing
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.