-
Notifications
You must be signed in to change notification settings - Fork 0
LCOV formatting
Cédric Belin edited this page Apr 10, 2025
·
5 revisions
Each class provided by this library has a dedicated ToString()
method returning the corresponding data formatted as LCOV string.
All you have to do is to create the adequate structure using these different classes, and to export the final result:
using Belin.Lcov;
using System;
var lineData = new[] {
new LineData { LineNumber = 6, ExecutionCount = 2, Checksum = "PF4Rz2r7RTliO9u6bZ7h6g" },
new LineData { LineNumber = 7, ExecutionCount = 2, Checksum = "yGMB6FhEEAd8OyASe3Ni1w" }
};
var sourceFile = new SourceFile("/home/cedx/lcov.net/fixture.cs") {
Functions = new FunctionCoverage { Found = 1, Hit = 1 },
Lines = new LineCoverage { Found = 2, Hit = 2, Data = lineData }
};
var report = new Report("Example", [sourceFile]);
Console.WriteLine(report);
The Report.ToString()
method will return a LCOV report formatted like this:
TN:Example
SF:/home/cedx/lcov.net/fixture.cs
FNF:1
FNH:1
DA:6,2,PF4Rz2r7RTliO9u6bZ7h6g
DA:7,2,yGMB6FhEEAd8OyASe3Ni1w
LF:2
LH:2
end_of_record
Tip
See the source code of this library for detailed information on the available classes.