Plain run:
cargo testUse -- to separate arguments for the cargo test subcommand and the
test application:
cargo test --help # Help text of the cargo test subcommand
cargo test -- --help # Help text of the test applicationBy default multiple tests are run in parallel in threads. To disable parallelism, set the number of threads to one:
cargo test -- --test-threads=1Print stdout also for passed tests:
cargo test -- --show-outputRun a subset of tests by name:
cargo test my_textOnly function whose name matches .*my_text.* will be run.
Ignore some tests by default:
#[cfg(test)]
mod tests {
#[test]
#[ignore]
fn my_test() {
// code that takes an hour to run
}
}To run ignored tests:
cargo test -- --ignored