Code Coverage#
Trident's code coverage feature analyzes which parts of your Solana program are tested during fuzzing sessions, helping you identify untested code paths and improve test effectiveness.
Key features:
- Real-time Analysis: Monitor coverage as fuzzing progresses
- Multiple Formats: Generate reports in JSON and HTML formats
- VS Code Integration: Visualize coverage directly in your IDE using Solana VS Code extension
- Detailed Reporting: Get insights into line coverage, branch coverage, and execution paths
Gathering Coverage Data#
- Enable coverage in the Trident manifest
- Deploy your program through the entrypoint
- Run the fuzz test
Viewing Coverage Reports#
You have two options for displaying coverage data: generate an HTML report for browser viewing, or generate a JSON report for VS Code integration.
HTML Report#
- Set
format = "html"
in the Trident manifest before running the fuzz test - Run the fuzz test
- After the fuzz test finishes, the HTML report will be stored in the
<fuzz-test-name>-coverage-report
folder - Open the HTML report in your browser
VS Code Extension#
- Set
format = "json"
in the Trident manifest before running the fuzz test - Run the fuzz test
- Install the Solana VS Code extension
- Run the VS Code command
Solana: Show Code Coverage
and select the "Load generated JSON report" option
Live Coverage Updates#
For real-time coverage monitoring during fuzzing:
- Set
format = "json"
in the Trident manifest - Set
loopcount
to a value other than0
e.g.,5
for frequent updates, for more info check out Trident manifest - Install the Solana VS Code extension
- Choose one of these options:
- Automatic: Set
attach_extension = true
in the Trident manifest to automatically show live updates while the fuzz test is running - Manual: Use the command
Solana: Show Code Coverage
and select the "Attach to active fuzzing session" option
- Automatic: Set