Closed DawChihLiou closed 1 year ago
Yes it's possible to use fixtures that are in separated modules or create. You should just then import them.
@la10736 thanks for getting back to me! Are there some examples I can follow? I'm not sure how to do it just by your comment. Thanks!
Sorry, I answered from my mobile and swipe introduced lot of craps in my answer. In https://github.com/la10736/rstest/blob/master/rstest/tests/resources/fixture/from_other_module.rs there is the example that I'm using in tests. I rewrote it here focused on reusable example
mod my_mod {
use rstest::fixture;
#[fixture]
pub fn mod_fixture() -> u32 {
42
}
}
use my_mod::mod_fixture;
use rstest::rstest;
#[rstest]
fn example(mod_fixture: u32) {
assert_eq!(42, mod_fixture);
}
Thank you so much @la10736. It's very clear!
Hi maintainer, thanks for the amazing crate! I'm wondering if there's a way to write fixtures in separate files. Some of my fixture sizes are vary large so I would love to put them in separate files and include them in tests. Would that be possible?