01What is LCOV Coverage Viewer?
lcov.info is the tracefile format written by LCOV's geninfo, and many other coverage tools produce it too, including several JavaScript test runners. It is plain text, but a real file runs to thousands of lines, and the numbers you want are spread across many records. This viewer reads it and shows a table of coverage per source file, with totals at the top. The format, as described in the geninfo(1) manual, groups data into blocks. Each block starts with SF:<path> and ends with end_of_record. Inside, DA lines give the execution count for each instrumented line. Functions use the older FN and FNDA pair, or, from LCOV 2.2 on, FNL and FNA, where several alias names share one index. Branches use BRDA lines, whose last field is either a count or a dash meaning the branch was never evaluated. LF/LH, FNF/FNH and BRF/BRH hold summary counts. The viewer counts from the detail records. A line is hit when its count is above zero. A function group is hit when any alias ran. A branch is hit when its taken value is a number above zero. Branch expressions may contain commas, so the parser takes the first two fields and the last one and keeps the rest as the expression. Branches flagged U, for unreachable, are left out, since the manual describes them as meant to be ignored in reports. When a file has no detail records, the summary lines are used instead. Blocks for the same SF path, for example from different TN test names, are merged. Take the Two JS files example. src/math.js has four DA lines, two with a count of 3 and two with 0, so lines show 50% (2/4). add ran three times and divide never ran, giving 50% (1/2) for functions. Its two branches have taken values 0 and a dash, so branches are 0% (0/2). src/util.js has two hit lines and no function or branch data, so those columns read n/a rather than 0%. The total row reads 66.67% (4/6) for lines. You can sort the table by file name or by any percentage. Copy gives a tab-separated version that pastes cleanly into a spreadsheet or a pull request. Records outside an SF block, malformed lines and a missing end_of_record show as warnings, and the rest of the file is still counted. MCDC records and source display are not supported. Nothing is uploaded.
Developers and reviewers who want a quick look at test coverage from an lcov.info file without generating an HTML report. The tool runs entirely in your browser, so your data never leaves your device.
02How to use LCOV Coverage Viewer
- Run your tests with lcov output enabled and open the lcov.info file
- Paste its contents into the input box, or load an example
- Read the line, function and branch totals at the top
- Click a column header to sort files by that metric, and click again to reverse
- Use Copy table to get tab-separated text you can paste elsewhere
03Worked examples
- Input:
Two JS files example: src/math.js with FN/FNDA for add (3) and divide (0), DA:1,3 DA:2,3 DA:5,0 DA:6,0, BRDA:6,0,0,0 and BRDA:6,0,1,-; src/util.js with DA:1,1 DA:2,1 - Result:
File Lines Functions Branches src/math.js 50% (2/4) 50% (1/2) 0% (0/2) src/util.js 100% (2/2) n/a n/a Total 66.67% (4/6) 50% (1/2) 0% (0/2) - Input:
LCOV 2.2 example: lib/x.c with FNL/FNA groups foo (aliases 0 and 2 calls) and bar (0), BRDA lines including f(a, b) and a U unreachable branch, split across TN:a and TN:b - Result:
File Lines Functions Branches lib/x.c 50% (1/2) 50% (1/2) 66.67% (2/3) Total 50% (1/2) 50% (1/2) 66.67% (2/3) - The two blocks for lib/x.c are merged, and the unreachable branch is left out.
- Input:
Summary lines only: SF:src/app.ts with LF:120 LH:96 FNF:14 FNH:11 BRF:40 BRH:25 and no detail records - Result:
File Lines Functions Branches src/app.ts 80% (96/120) 78.57% (11/14) 62.5% (25/40) Total 80% (96/120) 78.57% (11/14) 62.5% (25/40) - With no DA, FN or BRDA lines, the summary counts are used as they are.
- Input:
Broken tracefile: a DA line before any SF, DA:7,x inside src/api/handler.ts, and src/api/routes.ts with no end_of_record - Result:
File Lines Functions Branches src/api/handler.ts 66.67% (2/3) 100% (1/1) 50% (1/2) src/api/routes.ts 50% (1/2) n/a n/a Total 60% (3/5) 100% (1/1) 50% (1/2) Warnings: Line 1: "DA" outside an SF ... end_of_record block, ignored. / Line 7: bad DA record. / Last record has no end_of_record line. - Bad lines are skipped and reported, and the rest of the file is still counted.
04Common use cases
- Checking coverage from a CI artifact without running genhtml
- Finding the files with the lowest branch coverage before writing more tests
- Confirming that a test runner's lcov reporter writes function and branch data
- Pasting a coverage table into a pull request description
- Looking at an LCOV 2.2 tracefile that uses the newer FNL and FNA function records
- Working out why a coverage total looks wrong when a tracefile was cut off or concatenated badly
05Tips
- Sort by Branches ascending to find the files where tests miss the most decisions
- n/a means the file has no records of that kind, which differs from 0 percent
- If totals look too low, check the warnings for records that fell outside an SF block
- Very large tracefiles work, but pasting only the files you care about keeps the table short
06Related concepts
lcov, code coverage, branch coverage, tracefile, geninfo, genhtml.
Frequently Asked Questions
What is LCOV Coverage Viewer?
LCOV Coverage Viewer is a free, browser-based developer tool on AIDToolStack. Paste an lcov.info file and see line, function and branch coverage for each source file, with totals and sortable columns. Runs in your browser. It requires no installation or sign-up and works entirely in your browser.
Is LCOV Coverage Viewer free to use?
Yes. No sign-up, no fees and no usage cap.
Does LCOV Coverage Viewer store my data?
No. It runs in your browser; nothing is uploaded.