Use coverage tools to find code that needs more unit tests
(This is a placeholder ticket, made so that people can find it when they search for things to do under the First Contribution label.)
We try to use coverage tools to check how well our test code actually reaches all of our functions. Coverage reports are uploaded daily. To test your own changes to see whether you've improved coverage, you'll need to install a few extra tools:
- Use rustup to update to a recent rust version (1.60 or newer), if you haven't done so already:
rustup update
. - Install the grcov prerequisites and tools:
rustup component add llvm-tools-preview
cargo install grcov
- (if you run into trouble, see the grcov documentation.)
- In the arti source repository, run:
./maint/coverage unit
. This may take a long time. - Load in the newly created
coverage/all/index.html
file in your web browser, and you can inspect Arti's code coverage!
When you're writing new tests, make sure that your tests actually test the code that they're calling. It's no good to increase coverage just by calling the underlying code: a good test needs to make sure that the code works.
As a general rule, ask yourself: Would this test still pass if the code did the wrong thing? The answer should be "no".
Also ask yourself: would this test fail if the code did the right thing, but in a different way than it does now? Ideally, the answer should be "yes".