Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Makefile.test.include
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ GENERATED_TEST_FILES = $(JSON_TEST_FILES:.json=.json.h) $(RAW_TEST_FILES:.raw=.r

# test_unite binary #
UNITE_TESTS =\
test/fakeit/fakeit.hpp \
test/arith_uint256_tests.cpp \
test/scriptnum10.h \
test/addrman_tests.cpp \
Expand Down
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));
```
Loading