-
Notifications
You must be signed in to change notification settings - Fork 178
Open
Labels
Description
Motivation
Imagine a situation where you are refactoring code which are supposed to calls mocked methods in some "similar" order with similar parameters.
I checked the library and this equality testing of invocation history is not documented. I imagine something like this pseudo code:
int acceptance_test(){
Mock<SomeInterface> mock1;
Mock<SomeInterface> mock2;
OldAndCrusted reference;
NewAndUntrusted contestant;
SomeInterface &reference_mock = mock1.get();
SomeInterface &contestant_mock = mock2.get();
// Production code exhaustively testing things
reference.functionality(reference_mock);
contestant.functionality(contestant_mock);
// creating history objects
std::unordered_set<Invocation *> reference_history;
std::unordered_set<Invocation *> contestant_history;
// fill history objects
mock1.getActualInvocations( reference_history );
mock2.getActualInvocations( contestant_history );
// Compare histories
return compareHistoriesDifferenceExplaination(std::cout, reference_history, contestant_history);
}I am still unfamiliar with FakeIt and recently started contributing to a code base which uses it.
Questions
- Are there philosophical reasons why this use of FakeIt would be discouraged/"bad"?
- Does FakeIt or a different library extending it already provide convenience functions which could help implement
compareHistoriesDifferenceExplaination? - Are there any obvious problems with this approach which will complicate things, such as edge cases around comparing invocations of different
Mocks of mocking the same class called by different classes? - Is there any functionality or internal methods i should be aware of when implementing
compareHistoriesDifferenceExplaination? - Would
compareHistoriesDifferenceExplainationunder a less unwieldy name be an contribution the community appreciates?- If so how should this contribution be distributed? Does it have a place in the core FakeIt library or should be in a separate library?
In my case "similar" means identical. But i could see an extension of this to cover mocked calls having equality relations, properties like idem-potency and information whether certain calls commute given certain arguments being interesting to pursue further given an use case.