After playing around with adding a test trait implementation in one file
tests/test_impl.rs, and then using that implementation from within either
tests/lib.rs or another file in
tests, it appears that this does not work the way I’d expect. The tests use a macro defined in
src. If everything is in one file and I do the following
#[macro_use] extern crate fsm; the macros are loaded and work correctly.
But if I put the code that uses the macros into the
#[macro_use] extern crate fsm; in
tests/lib.rs the macros are not found in
test_impl.rs. If I add the same
#[macro_use] extern crate fsm; to
test_impl.rs the macros are found, but I can’t do this if I properly include the module in
mod test_impl; as the extern can’t be used in a module that isn’t the root of the crate.
cargo test --verbose it appears that each file is turned into it’s own binary, and that sharing code in the tests directory is not supported. I believe there are only two options here:
- Put shared test code in
- Add shared code with a non
.rsextension and use the
Has anyone had this problem before and are there any suggestions about the proper way to handle this? It seems like what should be a very common integration test use case using mock implementations, although I haven’t seen it done in any crates I explored on crates.io.