This might be my misunderstanding of how fixtures are supposed to work, but I would love the ability to have fixtures resolved exactly once per test.
For example, I have a mock struct (let's call it MyMock) that contains the current mocked state.
In my tests I want to use this struct to add some things to the current test environment.
For example:
#[test]
fn test_thing() {
let mock = MyMock::new();
let foo1: Foo = mock.add_foo("foo1");
let foo2: Foo = mock.add_foo("foo2");
// Now run the function-to-be-tested, which also requires `&MyMock`
let result = my_func(&mock).unwrap();
assert_eq!(result, foo1); // I need foo1 here.
}
Can I use fixtures to get both MyMock as well as one or more Foos, created from the same instance of MyMock ?
This might be my misunderstanding of how fixtures are supposed to work, but I would love the ability to have fixtures resolved exactly once per test.
For example, I have a mock struct (let's call it
MyMock
) that contains the current mocked state. In my tests I want to use this struct to add some things to the current test environment.For example:
Can I use fixtures to get both
MyMock
as well as one or moreFoo
s, created from the same instance ofMyMock
?For example, something like this?
Requirements:
MyMock
per test.Is this possible?
--
(as an aside, it gets tedious to write this kind of thing:
is there any way to improve that?)