Coverage
Coverage reporting allows developers to gain comprehensive insights into how their code is executed.
With cairo-coverage
, you can generate a coverage report that can later be analyzed for detailed coverage statistics.
Integration with cairo-coverage
snforge
is able to produce a file with a trace for each passing test (excluding fuzz tests).
All you have to do is use the --save-trace-data
flag:
$ snforge test --save-trace-data
The files with traces will be saved to snfoundry_trace
directory. Each one of these files can then be used as an input
for the cairo-coverage.
If you want snforge
to call cairo-coverage
on generated files automatically, use --coverage
flag:
$ snforge test --coverage
📝 Note To generate trace data files, it is required to use Scarb version
2.8.0
or higher and include the following in yourScarb.toml
file:[cairo] unstable-add-statements-code-locations-debug-info = true unstable-add-statements-functions-debug-info = true inlining-strategy = "avoid"
For more information about these sections, please refer to the Scarb documentation.