diff --git a/src/test/fakeit/README.md b/src/test/fakeit/README.md new file mode 100644 index 0000000000..941d4a992f --- /dev/null +++ b/src/test/fakeit/README.md @@ -0,0 +1,48 @@ +FakeIt +====== + +Unit-e uses (FakeIt 2.0.5)[]https://github.com/eranpeer/FakeIt/releases/tag/2.0.5] +for mocking interfaces in unit tests. + +FakeIt is a simple mocking framework for C++. It supports GCC, Clang and MS Visual C++. + +FakeIt is written in C++11 and can be used for testing both C++11 and C++ projects. + +```cpp +struct SomeInterface { + virtual int foo(int) = 0; + virtual int bar(string) = 0; +}; +``` +```cpp +// Instantiate a mock object. +Mock 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 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)); +```