-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<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)); | ||
``` |