-
Notifications
You must be signed in to change notification settings - Fork 15
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
add fakeit mocking header library for unit tests #171
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is cool to have a mocking library.
utACK
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ConceptACK
❤️ utACK bfe6917 |
utACK, very cool. |
@Ruteri The linter failed on whitespace in the README. |
Extracted from #137 This includes the header-only [fakeit](https://github.com/eranpeer/FakeIt) library into the unit test target (so no dependencies added to `united` etc.). `fakeit` can mock interfaces (anything which `std::is_polymorphic` yields true for ;-)). Here are usage examples extracted from their README: ```cpp class SomeInterface { virtual int foo(int) = 0; virtual int bar(string) = 0; }; ``` ```cpp // Instantiate a mock object. Mock<SomeInterface> mock; // Setup mock behavior. When(Method(mock,foo)).Return(1); // Method mock.foo will return 1 once. // Fetch the mock instance. SomeInterface &i = mock.get(); // Will print "1". cout << i.foo(0); ``` Verify method invocation ```cpp Mock<SomeInterface> mock; When(Method(mock,foo)).Return(0); SomeInterface &i = mock.get(); // Production code i.foo(1); // Verify method mock.foo was invoked. Verify(Method(mock,foo)); // Verify method mock.foo was invoked with specific arguments. Verify(Method(mock,foo).Using(1)); ```
Extracted from #137
This includes the header-only fakeit library into the unit test target (so no dependencies added to
united
etc.).fakeit
can mock interfaces (anything whichstd::is_polymorphic
yields true for ;-)).Here are usage examples extracted from their README:
Verify method invocation