Having created a new binary using Cargo
cargo new my_binary --bin
Now adding a function to my_binary/src/main.rs can be used for a test, eg:
#[test]
fn my_test() {
println!("Test OK");
}
Now cargo test -- --nocapture runs the test as expected.
My question is, whats the most straightforward way to move these tests into a separate file?
I tried to define a crate and move the source to tests/main.rs but it wasn't automatically found.
Probably am missing something, but didn't manage to get this working following online docs.
Aucun commentaire:
Enregistrer un commentaire