Reputation: 127781
I'm writing a crate which consists of multiple modules spread across multiple files. These modules are interdependent, i.e. some of the modules use other modules inside this crate.
Is it possible to run tests in such modules separately from other modules in the crate? Running rust test some_module.rs
does not work if some_module.rs
contains references to other modules in this crate. Running rust test my_crate.rc
does work, but it runs tests from all of crate modules, which is not what I want.
Upvotes: 2
Views: 573
Reputation: 102076
It is possible to run a subset of the tests:
> rustc --test my_crate.rc
> ./my_crate some_module
... test output ...
This will run any function for which the full path contains some_module
. There is a fairly detailed help page for unit testing on the wiki, including this use case.
Note that rust test
doesn't support this (yet!), so you have to compile the test runner and invoke it by hand (or, write a Makefile/script to do it).
Upvotes: 3