Skip to content

Commit

Permalink
add README to test/fakeit/
Browse files Browse the repository at this point in the history
  • Loading branch information
scravy committed Oct 16, 2018
1 parent 98186c9 commit e72c766
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions src/test/fakeit/README.md
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));
```

0 comments on commit e72c766

Please sign in to comment.