合约的仓库是:
https://github.com/RohanNero/learn-foundry-coverage
首先使用如下命令生成 lcov 文件:
forge coverage --report lcov
生成了 lcov.info 文件后,再使用如下命令生成html:
genhtml lcov.info -o report --branch-coverage
但是报错:
Reading tracefile lcov.info.
genhtml: ERROR: (corrupt) unable to read trace file 'lcov.info': genhtml: ERROR: (inconsistent) "script/Counter.s.sol":7: function CounterScript.setUp found on line but no corresponding 'line' coverage data point. Cannot derive function end line. See lcovrc man entry for 'derive_function_end_line'.
(use "genhtml --ignore-errors inconsistent ..." to bypass this error)
(use "genhtml --ignore-errors corrupt ..." to bypass this error)