Code coverage shows which instrumented parts of a program ran while tests executed. It can help you find unvisited lines and decision paths, but a high percentage does not prove that tests assert the right behavior. Use coverage as a map for investigation—not as a stand-alone measure of test quality.
What code coverage measures
A coverage tool gathers execution data while a program runs, then compares that data with the source code or control-flow opportunities it recognizes. In practice, the workflow has three stages: build or instrument the program, run it under tests, and generate a report. The exact metrics and their meanings depend on the tool, so percentages from different tools should not be treated as directly comparable.
For example, Clang source-based coverage uses information from the compiler’s abstract syntax tree and preprocessor to map execution back to source. Other tools can use different approaches, including instrumentation of compiled code. A source-level report is therefore an interpretation produced by a specific tool and build, not a tool-independent census of program behavior. Clang’s source-based coverage documentation and JaCoCo’s control-flow analysis documentation describe their respective approaches.
Coverage metrics: what each one reveals
| Metric | What it asks | How to use it |
|---|---|---|
| Function coverage | Was each function executed at least once? | A coarse way to spot functions tests never enter; it says little about paths within a function. |
| Line coverage | Were executable source lines reached? | Useful for locating unvisited lines, but a line can contain multiple outcomes or regions. |
| Region coverage | Were the source regions recognized by the tool reached? | Offers finer detail than line coverage when one line contains multiple regions. |
| Branch coverage | Were the possible destinations or outcomes of decisions taken? | Helps expose an untested alternative, such as the false outcome of an if. |
| MC/DC | Could each condition independently affect a decision’s outcome? | A more demanding condition-level measure, relevant in contexts such as embedded software. |
Clang reports function, instantiation, line, region and branch coverage, with optional MC/DC. In Clang’s model, function coverage is generally the least granular and branch coverage with MC/DC the most granular; for a function, 100% branch coverage implies 100% region coverage. Those relationships describe Clang’s metrics, not a universal conversion between tools. See the Clang metric definitions before interpreting its report.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware match#1 Best Overall
Why branch coverage can matter when lines are covered
Suppose a function contains an if statement. Tests may execute the condition and every line in the function while taking only the true outcome. Line coverage can make the function look fully visited, even though the false destination has not been exercised. Branch coverage records those decision destinations and can flag the missing path.
Coverage.py’s branch coverage guide demonstrates this distinction: its branch mode records source-to-destination line transitions, so a missing jump can be reported even when statement coverage has reached each line. The tool supports text, HTML, XML and JSON reports.
Collect coverage with Clang and LLVM
The following is the basic source-based coverage sequence documented by Clang. Run it from a shell in the directory containing foo.cc:
-
Compile with instrumentation and coverage mapping enabled:
Recommended Free Tools
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.Rank #2
Freestyle 5 Books of Freestyle Self Testing Log Book Total 5 Books- The FreeStyle log book includes sections for: Lunch, Dinner, Bedtime, Night
- Comments for each day of the week
- Log Book Dimensions L=4.25" x W=3.12" x H=0.12"
- Contains 5 book
clang++ -fprofile-instr-generate -fcoverage-mapping foo.cc -o foo -
Run the instrumented program. It writes raw profile data when it exits:
./foo -
Merge and index the raw profile data:
llvm-profdata merge -sparse foo.profraw -o foo.profdata -
Display a line-oriented report:
llvm-cov show ./foo -instr-profile=foo.profdata
By default, the program writes raw data to a profile file; set LLVM_PROFILE_FILE when you need to choose its path. The llvm-profdata merge step turns raw profile data into an indexed profile that llvm-cov can read. For machine-readable output, Clang also documents llvm-cov export. Full command and output options are in the Clang coverage guide.
Collecting MC/DC with Clang
To collect MC/DC data, compile with -fcoverage-mcdc in addition to the source-based coverage flags, then request the summary with -show-mcdc-summary when displaying the report. MC/DC examines whether each individual condition can affect a decision outcome, accounting for other conditions or short-circuit masking. Use it when that extra condition-level evidence serves a concrete testing or assurance need; it is more detailed than simply checking whether lines ran.
Turn uncovered code into better tests
Use the report to ask what behavior is missing, then decide whether a test is warranted. A useful cycle is:
Free tools Windows power users keep installed
One-click scans. No signup required.
Rank #3
- PRIVATE PILOT STUDY SYSTEM FOR EVERY STAGE OF TRAINING - 308 physical flashcards help student pilots build foundational knowledge, reinforce concepts behind the written test, practice for the oral exam, prepare for ground lessons and mock orals, and refresh knowledge for flight reviews.
- STOP REVIEWING EVERYTHING EQUALLY - Use the included New, Review, and Checkride Ready dividers to organize all 308 cards by your actual understanding. Keep unfamiliar material in New, move developing topics into Review, and advance cards you can explain accurately into Checkride Ready so each study session focuses on what still needs work.
- PRACTICE ANSWERING, EXPLAINING & APPLYING - Work through direct-recall and scenario-based questions without multiple-choice prompts. Answer aloud, explain why the answer is correct, apply it to a flight or aircraft, then compare your response and identify missing details before moving on.
- ACS-MAPPED WITH FAA REFERENCES - 7 color-coded sections organize Private Pilot knowledge into focused, one-concept-per-card questions with applicable ACS task codes and FAA references for deeper study. Developed with flight instructors to complement ground school, FAA publications, written-test preparation, and instructor training.
- PREMIUM PHYSICAL STUDY, WITHOUT ANOTHER SUBSCRIPTION - Study at home, at the airport, between lessons, or with your instructor with no app, login, charger, or subscription required. The deck comes in a rigid storage box and includes email support from an experienced flight instructor when you need additional help.
-
Run the existing test suite with the chosen coverage instrumentation and preserve the report for that run.
-
Inspect uncovered executable lines and, when available, the specific missing branch destinations.
-
For each gap, identify its behavioral meaning. It might be an error path, a boundary value, an alternate decision outcome, or code that is unreachable or no longer needed.
-
Add or improve a test when the gap represents intended behavior. Make the test assert the expected result or side effect; merely executing the code does not establish that the behavior is correct.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy. -
Rerun the suite and inspect what changed. If code genuinely cannot or should not be exercised, document the reason and use the tool’s exclusion mechanisms only where appropriate.
Coverage records execution, not whether an assertion would catch an incorrect result. A test can pass through a line without checking its effect, and a report cannot judge whether the test’s expectations are adequate. Treat uncovered code as a prompt to review tests and design—not as an automatic instruction to add a test for every line.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Read reports in the context of the tool and build
Compilation and instrumentation affect what a report can map back to source. JaCoCo, for example, analyzes control flow in Java class files; its source-line interpretation depends on those class files carrying debug line information, and its documented treatment does not count some implicit exceptions in the same way as explicit control flow. When a report seems surprising, check the tool’s metric definitions and the build artifacts it analyzes rather than assuming the percentage describes every possible runtime path.
Coverage needs practical infrastructure as well as a metric. Google’s account of its own coverage system describes layers for instrumentation, build integration, automation, visualization and analytics. The paper says line coverage was a practical choice in that organization because it was easy to visualize and correlated strongly with statement coverage there. That is an account of Google’s setting, not a guarantee that line coverage is the best metric for every team. Google’s Code Coverage at Google paper provides the organization’s description.
Best Value
Choose a metric for the testing question
-
Use function or line coverage to find code that tests do not reach at all.
-
Use branch coverage when alternate outcomes of decisions matter, particularly where all lines can run without every outcome being taken.
-
Use region coverage or MC/DC when the additional detail is relevant to your code and assurance needs.
-
Check the chosen tool’s definitions before comparing reports or percentages across languages, build configurations or coverage tools.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
There is no universal coverage percentage established by these tool descriptions. A useful report is one that helps you identify meaningful behavior that lacks a test and then verify that a new or improved test checks it.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

