--bins
и --lib
не являются исключительными, вы можете использовать оба, и он будет запускать тесты в обеих категориях:
$ cargo test --bins
Finished dev [unoptimized + debuginfo] target(s) in 0.01s
Running target/debug/deps/foo-c982c1477aaaf33d
running 1 test
test test_bins ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
$ cargo test --lib
Finished dev [unoptimized + debuginfo] target(s) in 0.02s
Running target/debug/deps/foo-532806c187f0c643
running 1 test
test test_lib ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
$ cargo test --bins --lib
Finished dev [unoptimized + debuginfo] target(s) in 0.02s
Running target/debug/deps/foo-532806c187f0c643
running 1 test
test test_lib ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
Running target/debug/deps/foo-c982c1477aaaf33d
running 1 test
test test_bins ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
Тестовый проект имеет интеграционный тест, который запускается, если цель не указана:
$ cargo test
Compiling foo v0.1.0 (foo)
Finished dev [unoptimized + debuginfo] target(s) in 0.27s
Running target/debug/deps/foo-532806c187f0c643
running 1 test
test test_lib ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
Running target/debug/deps/foo-c982c1477aaaf33d
running 1 test
test test_bins ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
Running target/debug/deps/test_foo-79419bfea3135abf
running 1 test
test test_integration ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
Doc-tests foo
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out