How and where would one write utility-code for test-functions in Rust?
For example, I have the following code defining a path where generated files can be placed:
fn gen_test_dir() -> tempdir::TempDir {
tempdir::TempDir::new_in(Path::new("/tmp"), "filesyncer- tests").unwrap()
}
This function is defined in tests/lib.rs
and is used in the tests in that file. However, I would also like to use this function in the unittests declared by #[test]
located in the src/lib.rs
.
Is this possible to achieve without compiling the utility-function into the non-test binary and without duplicating code?
Aucun commentaire:
Enregistrer un commentaire