Just an Anon Dev doing some MEV stuff on this thing called the EVM https://twitter.com/devanoneth
Just an Anon Dev doing some MEV stuff on this thing called the EVM https://twitter.com/devanoneth


Share Dialog
Share Dialog

Subscribe to Devan Non

Subscribe to Devan Non
<100 subscribers
<100 subscribers

Yeah, I know you’ve probably heard about the hype by now. People are flocking to Foundry and there’s nothing you can do about it. So, strap in, there’s been a new release which brings coverage reporting!
First, make sure you’re on the latest version of Foundry. If you don’t have it, get it here.
If you do have it installed already, get the latest version by running:
$ foundryup
To get a coverage report, it all starts with:
$ forge coverage
By default this will display a summary, which will look like this:

It’s already quite nice, but you can change the output via the --report flag. In order to get the coverage displayed nicely in VS Code, we need to use the LCOV reporter. So, run:
$ forge coverage --report lcov
You should now have a lcov.info file in your project directory. LCOV files can be parsed by many tools / extensions. In the case of VS Code I recommend Coverage Gutters.
Install the Coverage Gutters extension.
Open the file you want to see coverage results for.
Open the command palette in VS Code (CMD+SHIFT+P or CTRL+SHIFT+P by default) and type “Display Coverage”, you should see the option “Coverage Gutters: Display Coverage“, select it.
Now, your file should be nicely colored line-by-line showing if a line has been hit or not (green for hit, red for missed).

Obviously, there are some issues present. The constructor is definitely being hit in my tests, but it’s showing as a miss! Coverage in Foundry is still very much a work-in-progress, but it’s great that we have an initial version so we can start setting up our tooling and processes around it. Knowing the Foundry team, this feature will quickly blossom into another example of what the premier Solidity testing framework has to offer.
All the examples in this repo were performed on my ERC4626Votes repo.
Onbjerg has a nice example repo which includes the Codecov GitHub action. He also built the actual coverage feature, so kudos to him!

Yeah, I know you’ve probably heard about the hype by now. People are flocking to Foundry and there’s nothing you can do about it. So, strap in, there’s been a new release which brings coverage reporting!
First, make sure you’re on the latest version of Foundry. If you don’t have it, get it here.
If you do have it installed already, get the latest version by running:
$ foundryup
To get a coverage report, it all starts with:
$ forge coverage
By default this will display a summary, which will look like this:

It’s already quite nice, but you can change the output via the --report flag. In order to get the coverage displayed nicely in VS Code, we need to use the LCOV reporter. So, run:
$ forge coverage --report lcov
You should now have a lcov.info file in your project directory. LCOV files can be parsed by many tools / extensions. In the case of VS Code I recommend Coverage Gutters.
Install the Coverage Gutters extension.
Open the file you want to see coverage results for.
Open the command palette in VS Code (CMD+SHIFT+P or CTRL+SHIFT+P by default) and type “Display Coverage”, you should see the option “Coverage Gutters: Display Coverage“, select it.
Now, your file should be nicely colored line-by-line showing if a line has been hit or not (green for hit, red for missed).

Obviously, there are some issues present. The constructor is definitely being hit in my tests, but it’s showing as a miss! Coverage in Foundry is still very much a work-in-progress, but it’s great that we have an initial version so we can start setting up our tooling and processes around it. Knowing the Foundry team, this feature will quickly blossom into another example of what the premier Solidity testing framework has to offer.
All the examples in this repo were performed on my ERC4626Votes repo.
Onbjerg has a nice example repo which includes the Codecov GitHub action. He also built the actual coverage feature, so kudos to him!
No activity yet