January 2018
Beginner to intermediate
454 pages
10h 8m
English
Sometimes, we have tests that take a lot of time, or we want to avoid running a specific test all the time. To avoid running a test by default, we can add the #[ignore] attribute above the function:
#[ignore]
#[test]
fn test_dummy() {
assert!(false, "Always fail");
}
When we run the test, we'll see that the test function was not running:
Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs
Running target/debug/deps/ftp_server-452667ddc2d724e8
running 2 tests
test codec::tests::test_dummy ... ignored
test codec::tests::test_encoder ... ok
test result: ok. 1 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out
As you can see, the test_dummy() test function was ignored. To run it, we need to specify a command-line ...
Read now
Unlock full access