C++ mocking made easy. A simple yet very expressive, headers only library for c++ mocking.

FakeIt

Join the chat at https://gitter.im/eranpeer/FakeIt

GCC: Build Status GCC Coverage Status

MSC: Build status MSC

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.

struct SomeInterface {
	virtual int foo(int) = 0;
	virtual int bar(string) = 0;
};
// 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

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));

Checkout the Quickstart for many more examples!

The master branch has the stable version of FakeIt. Include the most suitable single header in your test project and you are good to go.

Features

  • Packaged as a single header file.
  • Very simple API based on the expressiveness of C++11.
  • Supports all major compilers: GCC, Clang and MSC++.
  • Easily integrated with GTest, MS Test and Boost Test.
  • Expressive Arrange-Act-Assert syntax.
  • Create mock classes or spy existing objects instantly in one simple line.
  • No limitation on number of method arguments.
  • Supports dynamic casting.

Installation

FakeIt is a header only framework. It does not require any installation. For extra simplicity fakeit is packaged as a single header file.

FakeIt is pre-configured to work with some of the major unit testing frameworks. A pre-configured version will use the assertions mechanism of the unit testing framework to integrate the generated error messages into the unit testing framework output.

If you don't find your unit testing framework on the list, simply use the standalone configuration.

Using a pre-packaged single header file

Pre-packaged single header versions of FakeIt are located under the single_header folder. Depending on the unit testing framework you use, simply add one of the pre-packaged versions to the include path of your test project:

  • <fakeit_folder>/single_header/gtest
  • <fakeit_folder>/single_header/mstest
  • <fakeit_folder>/single_header/boost
  • <fakeit_folder>/single_header/catch (Tested with Catch 2.0.1)
  • <fakeit_folder>/single_header/tpunit
  • <fakeit_folder>/single_header/mettle
  • <fakeit_folder>/single_header/qtest
  • <fakeit_folder>/single_header/nunit - (See caveats in config/nunit/fakeit_instance.hpp)
  • <fakeit_folder>/single_header/cute
  • <fakeit_folder>/single_header/standalone

For example, to use fakeit with Google Test simply add the single_header/gtest folder to the include path of your test project:

-I"<fakeit_folder>/single_header/gtest"

Using the source header files

Fakeit source code header files are located under the include foler. To use FakeIt directly from the source code all you need to do is to download the source files and add the include folder and the configuration folder of your choice to the include path of your project. For example:

  • To use fakeit with Google Test add the include folder and the config/gtest folder to the include path of your test project:
-I"<fakeit_folder>/include" -I"<fakeit_folder>/config/gtest"
  • To use fakeit with MS Test add the include folder and the config/mstest folder to the include path of your test project:
-I"<fakeit_folder>/include" -I"<fakeit_folder>/config/mstest"
  • To use fakeit with Boost Test add the include folder and the config/boost folder to the include path of your test project:
-I"<fakeit_folder>/include" -I"<fakeit_folder>/config/boost"
  • To use fakeit with Catch add the include folder and the config/catch folder to the include path of your test project:
-I"<fakeit_folder>/include" -I"<fakeit_folder>/config/catch"
  • To use fakeit with tpunit add the include folder and the config/tpunit folder to the include path of your test project:
-I"<fakeit_folder>/include" -I"<fakeit_folder>/config/tpunit"
  • To use fakeit with Mettle add the include folder and the config/mettle folder to the include path of your test project:
-I"<fakeit_folder>/include" -I"<fakeit_folder>/config/mettle"
  • To use fakeit with QTest add the include folder and the config/qtest folder to the include path of your test project:
-I"<fakeit_folder>/include" -I"<fakeit_folder>/config/qtest"
  • To use fakeit with NUnit in a managed Visual Studio C++/CLI project, add the standalone/nunit folder to your project include path. Note, it is useful to define your mocks in #pragma unmanaged sections so that you can use lambda expressions.

  • To use fakeit with CUTE add the include folder and the config/cute folder to the include path of your test project:

-I"<fakeit_folder>/include" -I"<fakeit_folder>/config/cute"
  • To use fakeit without any testing framework integration (standalone) add the include folder and the config/standalone folder to the include path of your test project:
-I"<fakeit_folder>/include" -I"<fakeit_folder>/config/standalone"

It is recommended to build and run the unit tests to make sure FakeIt fits your environment.

For GCC, it is recommended to build the test project with -O1 or -O0 flags. Some features of Fakeit may not work with stonger optimizations!!

Building and Running the Unit Tests with GCC

cd build
make all

run the tests by typing

./fakeit_tests.exe

Building and Running the Unit Tests with Clang

cd build
make -f clang_makefile all

run the tests by typing

./fakeit_tests.exe

Building and Running the Unit Tests with Visual Studio

Open the tests/all_tests.vcxproj project file with Visual Studio. Build and run the project and check the test results.

Limitations

  • Currently only GCC, Clang and MSC++ are supported.
  • On GCC, optimization flag O2 and O3 are not supported. You must compile the test project with -O1 or -O0.
  • In MSC++, your project must have Edit And Continue debug mode on (https://msdn.microsoft.com/en-us/library/esaeyddf.aspx) which is same of /ZI compiler switch. If you don't use this, you will have exceptions mocking destructors (which includes unique_ptr and other smart pointers).
  • Can't mock classes with multiple inheritance.
  • Can't mock classes with virtual inheritance.
  • Currently mocks are not thread safe.
Comments
  • what if I need to use shared_ptr or unique_ptr of the mock object in my unittest

    what if I need to use shared_ptr or unique_ptr of the mock object in my unittest

    The code is like this struct Paint { Paint(shared_ptr p_pen) :m_pen(p_pen) {};

    void RePain() { m_pen->Do(); }

    shared_ptr m_pen; }

    struct IPen { virtual Do() =0; }

    When I testing Paint, I want to pass a mocked IPen into Paint. But how can I pass the shared_ptr of IPen into Paint?

    If I can change the design to make Paint to have reference on IPen might be better. But If there a solution that I can use mock a shared_ptr?

  • Verify methods with parameters passed by reference

    Verify methods with parameters passed by reference

    Hello,

    We have interfaces with methods that take parameters by reference. Stubing such methods seem to work but when trying to Verify invocations, I got troubles.

    struct SomeInterface {
      virtual ~SomeInterface() {}
      virtual int foo(int&) = 0;
    };
    
    TEST_CASE("FakeIt integration", "[fakeit]") {
      Mock<SomeInterface> mock;
      When(Method(mock, foo)).AlwaysDo([](int& i)
      {
        std::cout << i << std::endl;
        return 1;
      });
      auto &si = mock.get();
      SECTION("We mock a method with param passed by reference") {
          auto i = 0;
          REQUIRE(si.foo(i) == 1);
          ++i;
          REQUIRE(si.foo(i) == 1);
          Verify(Method(mock, foo).Using(0), Method(mock, foo).Using(1)).Once();
      }
    }
    

    I got the following output:

    0
    1
    ...
    ... some lines related to Catch output
    ...
      Verification error
      Expected pattern: mock.foo(0) ... mock.foo(1)
      Expected matches: exactly 1
      Actual matches  : 0
      Actual sequence : total of 2 actual invocations:
        mock.foo(1)
        mock.foo(1)
    

    All the invocations seem to be done with last value of the parameter.

    Is there a way to indicate to FakeIt that this parameter should be treated as by copy. Here we only pass it by reference for optimization purpose.

    Thanks for your help

    Sincerely

    Bertrand

  • Support for x64 on VS2015 and VS2013

    Support for x64 on VS2015 and VS2013

    Unit tests for FakeIt is failing on Visual Studio. By looking at the code I believe it came from:

    1. pointers being converted to int leading to seg-fault. (int is still 32bit on x64 Visual Studio)
    2. There might be changes in the "header" of the VTable.

    Is FakeIt planning to support x64 on Windows? If so let's get this fixed I don't minding lending a hand=)

  • SIGSEGV when when mock with shared_ptr

    SIGSEGV when when mock with shared_ptr

    My code: auto mock1 = new Mock(); When(Method(*mock1, resId)).AlwaysReturn("1"); auto meta = shared_ptr(&mock1->get());

    error info: FATAL ERROR: test case CRASHED: SIGSEGV - Segmentation violation signal error in "method(c);" (line: 5541)

  • exception with unique_ptr

    exception with unique_ptr

    //Constructing real class is fine unique_ptr scheduler = make_unique((unique_ptr)make_unique());

    //Moc class caused exception Mock schedulerCoreMock; unique_ptr scheduler = make_unique(unique_ptr(&schedulerCoreMock.get(), {}));

    //TimeLineScheduler constructor and destructor TimeLineScheduler::TimeLineScheduler(std::unique_ptr schedulerCore) :_playingMediaEntities(std::make_shared()) , _schedulerCore(move(schedulerCore)) { _schedulerCore->setPlayingMediaEntities(_playingMediaEntities); }

    TimeLineScheduler::~TimeLineScheduler() = default;

    //Exception info: 0x0000000000000000 Exception raised at TimelineUnitTest.exe: 0xC0000005: Access conflict occurred at execution location 0x0000000000000000.

    //Call stack:

    TimeLineUnitTest.exe!fakeit::VirtualTablekompasstimeline::ITimeLineSchedulerCore::dtor(int __formal) 行 5541 C++ TimeLineScheduler::~TimeLineScheduler() = default;

  • String literals not being matched correctly v2.0.7.

    String literals not being matched correctly v2.0.7.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    a.out is a Catch v2.13.4 host application.
    Run with -? for options
    
    -------------------------------------------------------------------------------
    PseudoSensor::temp() generates a `card.temp` request
    -------------------------------------------------------------------------------
    pseudo-sensor.test.cpp:11
    ...............................................................................
    
    pseudo-sensor.test.cpp:27: FAILED:
      Verify( mock_notecard.newRequest("card.temp") )
    with message:
      pseudo-sensor.test.cpp:27: Verification error
      Expected pattern: mock_notecard.newRequest("card.temp")
      Expected matches: exactly 1
      Actual matches  : 0
      Actual sequence : total of 1 actual invocations:
        mock_notecard.newRequest("card.temp")
    
    ===============================================================================
    test cases: 1 | 1 failed
    assertions: 1 | 1 failed
    

    I ran the verification with increasing requirements to narrow it down, for example...

    fakeit::Verify(Method(mock_notecard,newRequest));                           // passes
    fakeit::Verify(Method(mock_notecard,newRequest)).Once();                    // passes
    fakeit::Verify(Method(mock_notecard,newRequest).Using("card.temp")).Once(); // fails
    

    The call in the implementation under test looks like this:

    _notecard.newRequest("card.temp");
    

    The signature of the mocked method is:

    virtual J *  newRequest(const char *) = 0;
    
  • Issue with mock with shared_ptr used in self-invocation

    Issue with mock with shared_ptr used in self-invocation

    I've created a test to capture this issue, but didn't find out how to fix yet.

    
    	class ISomeInterface3 {
    	public:
    		virtual ~ISomeInterface3() { }
    		
    		virtual void methodWithSomeSharedPointer(std::shared_ptr<ISomeInterface3> listener) = 0;
    	};
    
    	void production_shared_ptr_mock_used_in_invocation() {		
    		Mock<ISomeInterface3> mockDevAssertListener;
    		std::shared_ptr<ISomeInterface3> devAssertListener = std::shared_ptr<ISomeInterface3>(&mockDevAssertListener.get());
    
    		fakeit::Fake(Dtor(mockDevAssertListener));						
    		fakeit::Fake(Method(mockDevAssertListener, methodWithSomeSharedPointer));
    						
    		devAssertListener->methodWithSomeSharedPointer(devAssertListener);
    		devAssertListener = nullptr;
    	}
    

    I think this issue happens because some of the invocations store the shared_ptr and because of the order things are destructed it calls the destructor after the internal mock object is killed.

  • Mocking classes that exceed 50 virtual abstract methods segafults in runtime

    Mocking classes that exceed 50 virtual abstract methods segafults in runtime

    In such case, the Access Violation exception is thrown at: VTUtils.hpp:33

    Environment: Windows 7 Compilers: VS 2013 (64 bit) as well as gcc (i686-posix-dwarf-rev2, Built by MinGW-W64 project) 4.9.1

  • Formatter can not format enum type and causes SIGSEGV

    Formatter can not format enum type and causes SIGSEGV

    Formater can not format enum type argument and cause SIGSEGV when Exactly not match

    `a

    0x00007f8ee45d9ec6 in std::basic_ostream<char, std::char_traits<char> >& std::operator<< <char, std::char_traits<char>, std::allocator<char> >(std::basic_ostream<char, std::char_traits<char> >&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) () from /usr/lib/libstdc++.so.6
    (gdb) bt
    #0  0x00007f8ee45d9ec6 in std::basic_ostream<char, std::char_traits<char> >& std::operator<< <char, std::char_traits<char>, std::allocator<char> >(std::basic_ostream<char, std::char_traits<char> >&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) () from /usr/lib/libstdc++.so.6
    #1  0x000055da09ab2de9 in fakeit::Formatter<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, void>::format (val=...)
        at /root/ha-engine/third/FakeIt/single_header/catch/fakeit.hpp:298
    #2  0x000055da09ab2bf6 in fakeit::TuplePrinter<std::tuple<hasync::EventType, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&> const&, 2ul>::print (
        strm=..., t=...) at /root/ha-engine/third/FakeIt/single_header/catch/fakeit.hpp:315
    #3  0x000055da09ab2b2d in fakeit::print<hasync::EventType, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&> (strm=..., t=...)
        at /root/ha-engine/third/FakeIt/single_header/catch/fakeit.hpp:335
    ``````
    
    code
    ``````
      enum EventType {
        File = 0,
        Dir,
      };
      virtual void notify_add_event(EventType event_type,
                                    const std::string& filepath) = 0;
      Fake(Method(appmanager_mock, notify_add_event));
      Verify(Method(appmanager_mock, notify_add_event)).Exactly(3);
    ```
    
    os:
    g++ (Alpine 9.3.0) 9.3.0
  • Catch2 warning suppression macros changed 10/27/2019

    Catch2 warning suppression macros changed 10/27/2019

    Catch2 changed their approach to warning suppression macros such that the "UNSUPPRESS" macros are no longer defined, which breaks compilation for single_header/catch/fakeit.hpp at line 1225.

    Read the commit message here for details: https://github.com/catchorg/Catch2/commit/849f2848bdf625a7b6248e4e62ba0e39ee609634#diff-a010dcdfe8ba1736a2dc3acde52c3e89

    Compilation succeeds if I change CatchAdapter::Fail() to:

    void fail(
            std::string vetificationType,
            Catch::SourceLineInfo sourceLineInfo,
            std::string failingExpression,
            std::string fomattedMessage,
            Catch::ResultWas::OfType resultWas = Catch::ResultWas::OfType::ExpressionFailed ){
        Catch::AssertionHandler catchAssertionHandler( vetificationType, sourceLineInfo, failingExpression, Catch::ResultDisposition::Normal );
        INTERNAL_CATCH_TRY { \
            CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \         // added line
            CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \
            catchAssertionHandler.handleMessage(resultWas, fomattedMessage); \
            CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \         // changed line
        } INTERNAL_CATCH_CATCH(catchAssertionHandler) { \
            INTERNAL_CATCH_REACT(catchAssertionHandler) \
        }
    }
    
  • Request: capture invocation arguments by value

    Request: capture invocation arguments by value

    I've run into a case where a stubbed method accepts a by-ref argument which gets destroyed by the time verification kicks in. To my understanding FakeIt records the reference itself as part of invocation, not a copy of the referenced object. This is understandable as some types may be non-copyable. Still it would help a lot if there was syntax for explicitly marking a parameter as record-by-value during stubbing, to avoid situation where verification crashes because the referenced object is no longer there.

  • fakeit from conan center doesn't get header with integration (e.g. header with gtest integration)

    fakeit from conan center doesn't get header with integration (e.g. header with gtest integration)

    I've tried out using the fakeit from conan center Have tried both both version 2.3.0 and 2.3.2 and specifying the fakeit "integration" option as "gtest".

    This correctly pulls in gtest as a conan dependency, but the header file is just the plane one without any integration. i.e. it's just using the one called "standalone".

    Seems like there is only one package. Either there should be a package based on each integration option, or there should be one package with all the headers, though the former would likely be preferred.

    https://conan.io/center/fakeit?tab=recipe&os=

    Seems it is choosing the specific header, but guessing we only build the package once, with the default option of standalone

        def package(self):
            self.copy(pattern="fakeit.hpp", dst="include", src=os.path.join(self._source_subfolder, "single_header", str(self.options.integration)))
    

    I only get one package file downloaded to my conan cache.

    .conan\data\fakeit\2.3.2\_\_\package\5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9
    

    I tried on another library (jasper) from conan center varied it's option for shared - and this worked to have a separate package for each option value.

  • Undefined sanitizer issue

    Undefined sanitizer issue

    https://github.com/arangodb/arangodb/blob/devel/tests/Sharding/ShardDistributionReporterTest.cpp#L136

    Maybe we are use it wrong? Cannot understand, both classes have virtual dtor. Also we use old version of fakeit, I tried new but nothing changed.

    clang is 14.0.6

    cmake .. -DUSE_ENTERPRISE=On -DUSE_MAINTAINER_MODE=On -DUSE_FAILURE_TESTS=On -DUSE_JEMALLOC=Off -DUSE_IPO=Off -DCMAKE_C_FLAGS="-fsanitize=address,undefined,float-divide-by-zero,leak -fno-sanitize=alignment" -DCMAKE_CXX_FLAGS="-fsanitize=address,undefined,float-divide-by-zero,leak -fno-sanitize=alignment" -DBASE_LD_FLAGS="-fuse-ld=lld -Wl,--build-id -fno-stack-protector" -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DUSE_FAIL_ON_WARNINGS=On
    
    ➜  arangodb git:(devel) ✗ ./build_aulsan/bin/arangodbtests --gtest_filter="*ShardDistributionReporterTest*"
    Note: Google Test filter = *ShardDistributionReporterTest*
    [==========] Running 8 tests from 1 test suite.
    [----------] Global test environment set-up.
    [----------] 8 tests from ShardDistributionReporterTest
    [ RUN      ] ShardDistributionReporterTest.a_healthy_instance_a_single_collection_of_three_shards_and_three_replicas
    /home/mbkkt/projects/arangodb/3rdParty/fakeit-gtest/fakeit.hpp:5278:47: runtime error: member call on address 0x7ffe801a0560 which does not point to an object of type 'arangodb::ClusterInfo'
    0x7ffe801a0560: note: object is of type 'fakeit::VirtualOffsetSelector'
     fe 7f 00 00  40 ae 0a 28 a5 55 00 00  07 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  80 04 1a 80
                  ^~~~~~~~~~~~~~~~~~~~~~~
                  vptr for 'fakeit::VirtualOffsetSelector'
    SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /home/mbkkt/projects/arangodb/3rdParty/fakeit-gtest/fakeit.hpp:5278:47 in 
    /home/mbkkt/projects/arangodb/3rdParty/fakeit-gtest/fakeit.hpp:5278:47: runtime error: member call on address 0x7ffe801a0560 which does not point to an object of type 'arangodb::CollectionInfoCurrent'
    0x7ffe801a0560: note: object is of type 'fakeit::VirtualOffsetSelector'
     fe 7f 00 00  40 ae 0a 28 a5 55 00 00  04 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  80 04 1a 80
                  ^~~~~~~~~~~~~~~~~~~~~~~
                  vptr for 'fakeit::VirtualOffsetSelector'
    SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /home/mbkkt/projects/arangodb/3rdParty/fakeit-gtest/fakeit.hpp:5278:47 in 
    
  • Colliding MockingContext ids when used in multiple translation units because of __COUNTER__

    Colliding MockingContext ids when used in multiple translation units because of __COUNTER__

    MyInterface.h

    #pragma once
    
    class MyInterface
    {
    public:
        virtual ~MyInterface() = default;
    
        virtual std::string        MyStringMethod() const = 0;
        virtual std::vector< int > MyVectorMethod() const = 0;
    };
    

    MyMock.h

    #pragma once
    
    #include <fakeit.hpp>
    
    #include "MyInterface.h"
    
    class MyMock : public fakeit::Mock< MyInterface >
    {
    public:
        void MyStringMethodStub();
        void MyVectorMethodStub();
    };
    

    MyMock.cpp

    #include "MyMock.h"
    
    void MyMock::MyStringMethodStub()
    {
        fakeit::When( Method( *this, MyStringMethod ) ).AlwaysReturn< std::string >( "MyString" ); // __COUNTER__ == 10
    }
    
    void MyMock::MyVectorMethodStub()
    {
        fakeit::When( Method( *this, MyVectorMethod ) ).AlwaysReturn< std::vector< int > >( { 1, 2, 3 } ); // __COUNTER__ == 11
    }
    

    MyMethodStubs.h

    #pragma once
    
    class MyMock;
    
    void MyVectorMethodStub( MyMock& myMock_ );
    void MyStringMethodStub( MyMock& myMock_ );
    

    MyMethodStubs.cpp

    #include "MyMethodStubs.h"
    
    #include <fakeit.hpp>
    
    #include "MyMock.h"
    
    void MyVectorMethodStub( MyMock& myMock_ )
    {
        fakeit::When( Method( myMock_, MyVectorMethod ) ).AlwaysReturn< std::vector< int > >( { 4, 5, 6 } ); // __COUNTER__ == 10
    }
    
    void MyStringMethodStub( MyMock& myMock_ )
    {
        fakeit::When( Method( myMock_, MyStringMethod ) ).AlwaysReturn< std::string >( "OtherString" ); // __COUNTER__ == 11
    }
    

    MyTest.cpp

    #include "MyMethodStubs.h"
    #include "MyMock.h"
    
    BOOST_AUTO_TEST_CASE( CollidingIdsTest )
    {
        MyMock myMock;
    
        MyVectorMethodStub( myMock ); // __COUNTER__ == 10 in MyMethodStubs.cpp
    
        myMock.MyStringMethodStub(); // __COUNTER__ == 10 in MyMock.cpp. Override previous stub with wrong id.
    
        auto myVector = myMock.get().MyVectorMethod(); // Calls MyStringMethod under the hood, leading to a crash
    }
    

    I am using Visual Studio 2017.

    The above code snippet is a simplified demonstration of the problem. It is a lot more difficult to pinpoint in a real test setup.

    I cannot propose a solution since I don't have a deep understanding of fakeit internal wizardry.

    This is a major show stopper to better architecture a testing setup, especially considering the bloating of obj files by fakeit symbols rapidly breaking the maximum number of sections allowed, requiring to either split the source files in multiple translation units, or using the /bigobj switch.

  • Can't mock override with ref-qualifiers?

    Can't mock override with ref-qualifiers?

    I have an interface with simple overloaded methods that I use as getter and setter: virtual auto Index() const& -> unsigned = 0; and virtual auto Index() & -> unsigned& = 0;

    I can't seem to mock them, especially the second one (the setter). When using OverloadedMethod, I get hit with a compilation error. I know there is a ConstOverloadedMethod, but I think it's missing a version of the macro supporting ref-qualifiers?

  • Add vcpkg installation instructions

    Add vcpkg installation instructions

    fakeit is available as a port in vcpkg, a C++ library manager that simplifies installation for fakeit and other project dependencies. Documenting the install process here will help users get started by providing a single set of commands to build fakeit, ready to be included in their projects.

    We also test whether our library ports build in various configurations (dynamic, static) on various platforms (OSX, Linux, Windows: x86, x64) to keep a wide coverage for users.

    I'm a maintainer for vcpkg, and here is what the port script looks like. We try to keep the library maintained as close as possible to the original library. :)

Related tags
Googletest - Google Testing and Mocking Framework

GoogleTest OSS Builds Status Announcements Release 1.10.x Release 1.10.x is now available. Coming Soon Post 1.10.x googletest will follow Abseil Live

Jan 9, 2023
The C Unit Testing Library on GitHub is a library designed for easy unit testing in C

The C Unit Testing Library on GitHub is a library designed for easy unit testing in C. It was written by Brennan Hurst for the purpose of providing a J-Unit-like testing framework within C for personal projects.

Oct 11, 2021
Header-only C++11 library for property-based testing.

autocheck Header-only C++11 library for QuickCheck (and later, SmallCheck) testing. Please consult the wiki for documentation. Install conan remote ad

Dec 22, 2022
C unit tests with a small header-only library.
C unit tests with a small header-only library.

C unit tests Minimalistic unit tests in C. Uses the __attribute__((constructor)) which, as far as I know, is supported by GCC and clang. So this proba

Dec 5, 2022
A modern, C++-native, header-only, test framework for unit-tests, TDD and BDD - using C++11, C++14, C++17 and later (or C++03 on the Catch1.x branch)
A modern, C++-native, header-only, test framework for unit-tests, TDD and BDD - using C++11, C++14, C++17 and later (or C++03 on the Catch1.x branch)

Catch2 v3 is being developed! You are on the devel branch, where the next major version, v3, of Catch2 is being developed. As it is a significant rewo

Jan 9, 2023
A modern, C++11-native, single-file header-only, tiny framework for unit-tests, TDD and BDD (includes C++98 variant)

lest – lest errors escape testing This tiny C++11 test framework is based on ideas and examples by Kevlin Henney [1,2] and on ideas found in the CATCH

Dec 28, 2022
C++ Unit Testing Easier: A Header-only C++ unit testing framework

CUTE C++ Unit Testing Easier: A Header-only C++ unit testing framework usually available as part of the Cevelop C++ IDE (http://cevelop.com) Dependenc

Dec 26, 2022
QuickCheck clone for C++ with the goal of being simple to use with as little boilerplate as possible.

RapidCheck RapidCheck is a C++ framework for property based testing inspired by QuickCheck and other similar frameworks. In property based testing, yo

Dec 27, 2022
Simple C testing framework

MrTest Simple C testing framework Usage Copy the mrtest.c and mrtest.h file into your project. In order to use the mrtest main: create a .c file that

Jul 20, 2022
Simple, fast, accurate single-header microbenchmarking functionality for C++11/14/17/20

ankerl::nanobench ankerl::nanobench is a platform independent microbenchmarking library for C++11/14/17/20. #includ

Dec 25, 2022
A simple, cross-platform, and continuously integrated C++14 project template

Project Name A simple, cross-platform, and continuously integrated C++14 project template. Making cross platform C++ projects is widely known to be a

Dec 5, 2022
A micro unit-testing library for C/C++

µ-test A micro unit testing framework for C/C++ to get you up and running with unit-testing ASAP (even without libc). Usage Simply include the C and h

Dec 8, 2021
A tool to test if a shared library is dlopen'ble

A tool to test if a shared library is dlopen'ble

Oct 17, 2021
Xerus - A general purpose library for numerical calculations with higher order tensors, Tensor-Train Decompositions / Matrix Product States and other Tensor Networks

About The xerus library is a general purpose library for numerical calculations with higher order tensors, Tensor-Train Decompositions / Matrix Produc

Apr 20, 2021
easy to use, powerful & expressive command line argument parsing for modern C++ / single header / usage & doc generation

clipp - command line interfaces for modern C++ Easy to use, powerful and expressive command line argument handling for C++11/14/17 contained in a sing

Dec 29, 2022
Adorad - Fast, Expressive, & High-Performance Programming Language for those who dare

The Adorad Language Adorad | Documentation | Contributing | Compiler design Key Features of Adorad Simplicity: the language can be learned in less tha

Dec 26, 2022
Header only C++14 mocking framework
Header only C++14 mocking framework

Trompeloeil Get: trompe l'oeil noun (Concise Encyclopedia) Style of representation in which a painted object is intended to deceive the viewer into be

Dec 29, 2022
Extremely simple yet powerful header-only C++ plotting library built on the popular matplotlib
Extremely simple yet powerful header-only C++ plotting library built on the popular matplotlib

matplotlib-cpp Welcome to matplotlib-cpp, possibly the simplest C++ plotting library. It is built to resemble the plotting API used by Matlab and matp

Dec 30, 2022
A headers only high performance C++ middleware framework/lib. See README for details.

# README # hmbdc is an open source headers only C++ framework and library built on top of various real-world tested lockfree algorithms that facilit

Nov 6, 2022
A Tcp/Ip stack implementation on top of Solarflare ef_vi, and a C++ headers only framework for tcp multiplexing client/server.

Efvitcp Efvitcp is a tcp library using Solarflare ef_vi interface on linux, and also a tcp multiplexing framework for both C++ client and server progr

Nov 26, 2022