tezvyn:

How does cargo differentiate unit and integration tests by location?

Source: doc.rust-lang.orgintermediate

This tests Rust test layout conventions. Unit tests live inside src files in cfg(test) modules; integration tests go in top-level tests/ files as separate crates. Red flag: saying integration tests need cfg(test) or can use private APIs.

This tests whether you understand Cargo's test compilation model and visibility rules. Unit tests belong inside the src directory, typically in a tests module annotated with cfg(test) so they compile only with cargo test and can access private items. Integration tests live in a top-level tests directory where Cargo compiles each file as a separate external crate using only the public API, so they do not need cfg(test). Red flag: claiming integration tests can call private functions or require cfg(test) to exclude them from builds.

Read the original → doc.rust-lang.org

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.

How does cargo differentiate unit and integration tests by location? · Tezvyn