March 2023

Skip Doctests When Running cargo test

I don't use doctests when I'm working on small, one-off Rust apps. The default functionality of cargo test it so run them. The result is an empty report that shows up last. It's no big deal but it throws me off seeing 0 passed in the report.

I use this in my cargo.toml file to turn off the tests and the subsequent report:

[lib]
test = false
doctest = false

It's a nice little quality of live improvement when you don't have doctests to run.

NOTE: the test = false also skips test in the top level lib.rs file which is nice if you don't have tests in there.

end of line