Skip to main content
Try out the RareSkills ZK AI Tutor!
Blog

Foundry forge coverage

Last updated on Nov 12, 2026
Topics:Foundry

Visual line coverage report with LCOV

forge coverage lcov report

If you run “forge coverage” in a Foundry project, you’ll get a table showing how much of your lines and branches are covered.

Foundry forge coverage

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

mkdir coverage

3. Run the following command

forge coverage --report lcov && genhtml lcov.info --branch-coverage --output-dir coverage

4. Open the following file

coverage/index.html

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.

Credits

This tutorial was created by Matteo Vendittoli, a student at the RareSkills blockchain bootcamp.

Addendum: Visual line coverage in Visual Studio Code

It is also possible to view line coverage directly inside Visual Studio Code. Credit to 0xasp_ on Twitter for sharing this with us (original tweet).

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

Originally Published Feb 8, 2023

Related posts

11 min read

Foundry Unit Tests

This article will describe how to create unit tests in Solidity using Foundry.

Last updated onNov 12, 2026
Read Article

6 min read

Solidity Mutation Testing

Mutation testing is a method to check the quality of the test suite by intentionally introducing bugs into the code and ensuring the tests catch the bug.

Last updated onNov 12, 2026
Read Article

1 min read

Verify Signature Solidity in Foundry

Here is a minimal (copy and paste) example of how to safely create and verify ECDSA signatures with OpenZeppelin in the Foundry environment.

Last updated onNov 12, 2026
Read Article

16 min read

Invariant Testing in Foundry

In this article, we will discuss invariants and how to perform an invariant test on Solidity smart contracts using Foundry test suites.

Last updated onNov 12, 2026
Read Article