You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am not sure if this can be actually done, but it would be great.
Maybe with a new Attribute, something like #[final]?
Let me explain with an example.
If I use the oncefixture to set up an environment (e.g., create a folder and/or some files),
it would be great to have them cleaned up only once, after a set of tests (all tests?) is done.
Something like this:
mod test {use rstest::*;#[fixture]#[once]fnsetup_folder() -> TempDir{/// Code to setup temp dir}#[rstest]fntest1(setup_folder:TempDir){/// Do stuff}#[rstest]fntest2(setup_folder:TempDir){/// Do stuff}#[final]fncleanup(){/// Cleanup TempDir}}
The text was updated successfully, but these errors were encountered:
Add I mentioned in the documentation "Take care that the #[once] fixture value will never be dropped." This limitation is due to that I have no idea of how to identify the end of the tests... 😢 rstest works on the top of standard cargo test and cannot have any control on tests lifetime. On rust per 1.0 there was a way to register an on exit hook but it was removed lot of time ago.
If I find a way to register a call back is invocated at the end of all tests that will open a way to a lot of new functionalities.
Anyway I used some work around based on arc+mutex and some hysteresis to start and tear down some docker containers in integration tests... But it's not a general purpose solution.
Hi, thanks for this crate!
I am not sure if this can be actually done, but it would be great.
Maybe with a new Attribute, something like
#[final]
?Let me explain with an example.
If I use the
once
fixture
to set up an environment (e.g., create a folder and/or some files),it would be great to have them cleaned up only once, after a set of tests (all tests?) is done.
Something like this:
The text was updated successfully, but these errors were encountered: