There are 3 kinds of tests that
cargo test runs:
- Unit tests in the main source
- Functional tests in the
- Doc tests in the main source
The should all be relatively easy if you have the library compiling, you just need to change the flags slightly. Given a crate that is compiled with a command line like
> rustc --crate-name foo --crate-type lib src/lib.rs
then compiling the unit tests should be something like
> rustc --crate-name foo src/lib.rs --test
That will give you a binary that can be run to run the tests.
Similarly, once you have compiled the library you can compile and link the functional tests against it
> rustc --crate-name bar tests/bar.rs --test --extern foo=libfoo.rlib
> rustc --crate-name baz tests/baz.rs --test --extern foo=libfoo.rlib
These will again build binaries that will run the tests when executed.
Finally, to run doc tests you need to use
rustdoc and link the compiled library in
> rustdoc --crate-name foo src/lib.rs --test --extern foo=libfoo.rlib
This will compile and run each of the doc-tests itself, not producing a binary like the other commands.
With each of these you will of course also need to be adding in all the necessary dev-dependencies, but that should be pretty straightforward if you have dependency management for the main library working.