Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
    Eran Pe'er
    There is a new open issue (#21) asking for "Support stub for output parameter". Any suggestions for API?
    Miles Rout
    How does this header possibly work. Mocking in C++?
    hi Im new to the framework, does FakeIt support stubbing non-virtual methods?
    Eran Pe'er
    No, fakeit can only handle virtual methods. This is because fakeit hacks the virtual table and can only manipulate the methods found there.
    Thanks for the response!! One more thing, is I see from GIT home that multiple inheritance is not supported.
    does this mean classes deriving from multiple classes cannot be mocked or just a subset of features from multiple inheritance isnt supported?
    Eran Pe'er
    As far as I remember RTTI may not work correctly. Other features should work just fine. But let me make a dee
    Let me check and I will give you a better answer.
    Also, I have a legacy C++ application that does not make use of C++11. Now since the FakeIt uses C++11 features, could you please tell me how to compile my gtest with the fakeit.hpp header. Since mine is a legacy application compiling the gtest fails to recognize the symbols in the fakeit.hpp header.
    The GIT page says FakeIt is compatible with C++ projects as well, but Im unable to figure out how to include the header into my project. thanks.
    related stack overflow question: http://tiny/paujkb98/stacques3364incl
    not sure if previous link wrks, http://tinyurl.com/nknvxz6
    Eran Pe'er
    Well, I checked. It is more than just the RTTI. FakeIt can't handle mocking of classes with multiple inheritance.
    In some cases, for example with MSVS, you can compile the test project with c++11 and leave the production project/dll with c++.
    Hmm, multiple inheritance might be a blocker for us! But thanks for getting back.

    Hi, I am currently working my way through the quickstart guide to get a feel for your library. Very interesting so far.
    In the chapter Argument Matching the given examples do not compile
    I guess instead of


    it should be

    Bruno Castro
    Hello everyone
    Could someone answer my question?

    Hello eranpeer.
    Recently I've read about your framework at github and I thought it could be really useful on my projects.
    For now, I'm trying to compile your example from the Quickstart page, but I'm having a problem on it: the g++ compiler gives

    fakeit.hpp:9297:9: error: expected constructor, destructor, or type conversion before(’ token
    main.cpp:15:1: note: in expansion of macro ‘When’

    when trying to compile this source:

    #include <string>
    #include "catch.hpp"
    #include "fakeit.hpp"
    using namespace std;
    using namespace fakeit;
    struct SomeInterface {
        virtual int foo(int) = 0;
        virtual int bar(string) = 0;
    Mock<SomeInterface> mock;

    Could you please help me with this? I apologize if the solution to the problem is something obvious that I should've known before writing this question.


    I opened eranpeer/FakeIt#134 for supporting

    #include <string>
    #include "tpunit++.hpp"
    #include "fakeit.hpp"
    using namespace fakeit;
    struct OperatorBoolTests : tpunit::TestFixture {
        OperatorBoolTests() :
        struct SomeInterface {
            virtual operator bool() = 0;
        void enum_class_arg() {
            Mock<SomeInterface> mock;
            //When(Method(mock, operator())).AlwaysReturn(true);
            When(OverloadedMethod(mock, operator(), bool(void))).AlwaysReturn(true);
            mock.get().operator bool();
            //Verify(OverloadedMethodMethod(mock, operator(), bool(void))).Exactly(1);
    } __OperatorBoolTests;

    I get compilation error

    In member function ‘void OperatorBoolTests::enum_class_arg()’:
    cc1plus: error: ‘operator()’ is not a member of ‘std::remove_reference<OperatorBoolTests::SomeInterface&>::type {aka OperatorBoolTests::SomeInterface}’

    Thx for help

    Hi eranpeer! Fakeit looks like a really nice way to do mocking in C++.
    I have two questions: does it work without RTTI? And does it require exceptions to be enabled?
    Thomas Piekarski
    Hello, is there a nuget package for FakeIt available at nuget.org or elsewhere? I see a build script for a nuget package in the repository, but can not find the package at nuget.