How to run library and integration tests only?

Viewed 700

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. I didn't find a way to run integration tests only or to skip doc or executable tests.

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

2 Answers

Well, I have found the solution.

Package manifest file (Cargo.toml) must be modified like this:

[lib]
doctest = false

[[bin]]
test = false

(since I can't format this in a comment...)

You need to specify your binary name (definitely if you have more than one):

[[bin]] 
name = "check_dir" 
test = false

[[bin]]
name = "other"
test = false
Related