It is important in development of anything (including Solana programs) to be able to track code coverage.
Is there a way to get the coverage for BPF/SBF-based tests?
It's not perfect, but if you can run your tests with solana-program-test
https://docs.rs/solana-program-test/latest/solana_program_test/ and use prefer_bpf(false)
, then the tests will run all in Rust, so you can do coverage reports, ie:
#[test]
fn my_test() {
let mut program_test = solana_program_test::ProgramTest::default();
program_test.prefer_bpf(false);
program_test.add_program(
"my-program",
my_program_id,
solana_program_test::processor!(my_programs_process_instruction),
);
}