Skip to content
Guilherme Kunigami edited this page Mar 14, 2019 · 4 revisions

Basic file hierarchy under src:

|-- tests
|   |-- my_test.rs
|   |-- mod.rs
`-- lib.rs

NOTE: nothing goes on main.rs

  • src/lib.rs:

    mod tests;

  • src/tests/mod.rs:

    mod my_test;

  • src/tests/my_test.rs:

.

#[test]
fn it_works() {
  assert_eq!(2 + 2, 4);
}

Running

Simplest:

cargo test --lib

Print output to stdout

cargo test --lib -- --nocapture

Clone this wiki locally