meekrosoft / fff

A testing micro framework for creating function test doubles
Other
788 stars 169 forks source link

How to have different mocks in different tests #135

Open brendan-simon-indt opened 2 months ago

brendan-simon-indt commented 2 months ago

Does FFF support having different mocks for a function in different tests (in the same test file)?

I tried mocking a function with various return values and it works great. I added another test which added a custom fake (as output values are returned via argument pointers), but then the original tests failed. I think I also got multiple definition errors, so I had to modify the code under test to have the weak attribute.

Just wondering if FFF can support multiple fakes per test and not have to modify the original source code under test.

Thanks, Brendan :)

owbear commented 1 month ago

Declare your mocks once and specify the behaviour in each test. RESET_FAKE() in between resets to the default behaviour