How to run library and integration tests only?

I have a project with a library and two executables. When I run cargo test , it runs five executables: the unit tests for the library and both executables, integration tests, and doc tests.

Since I have only library and integration tests, I get annoying output like:

running 0 tests                                                           
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

I have tried to filter it with Cargo parameters but failed. If I use --lib then no integration tests are run. Also I didn't find a way to run integration tests only or to skip doc or executable tests.

  1. Is there any way to run only integration and library unit tests?

  2. Rust Book recommends to move almost all code from main.rs to lib.rs. So why tests for binaries are exists by default?

1 Like

Well, I have found the solution.

Package manifest file (Cargo.toml) must have "test = false" and "doctest = false" in according sections.

2 Likes

@sharpMouse Cool, thanks for the followup, I was curious.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.