When I write only unit tests (functions in the main crate with
#[test] attribute) and integration tests (
*.rs files in the
/tests folder), a re-run of
cargo test finishes under 1 second, no matter how many small tests I wrote. Doctests (Rust code snippets inside documentation), OTOH, is a different story, it seems that Rust re-compile and re-run every single code snippet sequentially.
My questions are:
- Is my hypothesis true? That doctests re-compile and re-run sequentially?
- Why is it this way? What makes doctests so difficult to optimize?
- How to improve the speed of doctesting?