Skip to content

Running Rust Tests

Running testsΒΆ

The cargo test compiles a binary that is configured to run all the tests in parallel.

You can provide some configuration like not to run tests in parallel:

cargo test -- --test-threads=1

To see output of the program:

cargo test -- --nocapture

Running a subset of tests:

cargo test test_name
cargo test check_guess

You can run multiple tests by providing a common phrase in test names, for example this_test_will_pass and this_test_will_fail:

cargo test this

To ignore tests, you can add:

#[test]
#[ignore]
fn ignored_test() {
    assert!(true)
}