Foundry forge coverage
Updated: Apr 10
Visual line coverage report with LCOV
If you run "forge coverage" in a foundry project, you'll get a table showing how much of your lines and branches are covered.
If you want to see visually which lines and branches are or are not covered, use the following steps
Instructions to get line visual coverage in foundry
1. Install genhtml
brew install genhtml
2. Create a coverage directory in your foundry project
3. Run the following command
forge coverage --report lcov && genhtml lcov.info --branch-coverage --output-dir coverage
4. Open the following file
And you'll be able to see a coverage report like what you see at the top of the page.
No available formula with the name "genhtml". Did you mean ekhtml?
If you get this error, do
brew install ekhtml
and it will install genhtml.
This tutorial was created by Matteo Vendittoli, a student at the RareSkills blockchain bootcamp.
Addendum: Visual line coverage in Visual Studio Code
1. Install the Coverage Gutters extension in VSCode
2. Generate the coverage report
forge coverage --report lcov
3. Open the Command Palette
Pick display coverage report