Large projects should have only one integration test crates with several modules. On Cargo itself this refactor decreased the compile time by 3x and reduce on-disk artifacts by 5x (source).
tests/
it/
main.rs
foo.rs
bar.rs
Another improvement is to consolidate several tests into one, since Cargo runs tests binaries sequentially.
For internal library, avoid integration tests all together.
Avoid doc tests
[lib]doctest = false
prefer a separate test file
#[cfg(test)]mod tests; // tests in `tests.rs` file
another trick is to have a single test crate for the whole workspace, since the library is recompiled twice instead