-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Hi-Perf" (non-virtual) Dependency Injection #16
Comments
Thanks @paulreimer for the questions
One thing, which might be useful when using templates is to avoid writing macros, though. struct IStreamJustForTesting {
virtual ~IStreamJustForTesting () = default;
virtual void AppendPacket(Packet* new_packet) = 0;
virtual const Packet* GetPacket(size_t packet_number) const =0;
virtual size_t NumberOfPackets() const = 0;
}; di::bind<class Stream>.to<GMock<IStreamJustForTesting>() |
OK, sounds good. I'm still trying to understand the first "automatic mock injection" part. Actually my question was more about the "automatic mock generation" part (e.g. avoiding macros), looks like it is possible as in the final example. So, at least we can define the interface in C++ (even if the concrete class doesn't inherit it) and avoid the Also just to check if I understand correctly, but in the final example then any mocks generated for |
Right, Macros might be avoided with interfaces and GMock. Yes, exactly. No cost in production but dynamic dispatch in testing. |
If we are using the "Hi-Perf" Google.Mock feature
https://github.com/google/googletest/blob/master/googlemock/docs/CookBook.md#mocking-nonvirtual-methods
Then how does this affect the ideal use of GUnit?
GUnit.GMake
? (since we are using derived class template args, notstatic_cast<iface&>
)Boost.DI
? (I know, a question for a different repo)Or any other trade-offs from using non-virtual methods?
The text was updated successfully, but these errors were encountered: