Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
    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.
    Dolf Andringa

    Hi all, I want to test my own library that uses a 3rd party library. So I want to mock that 3rd party libary using fakeit. Is there a way to mock methods of the 3rd party class definition? I want to test that calling MyTest.begin() results in ExternLib.someFunc being called. Currently I am trying the following, but that results in 'fakeit::SequenceVerificationException because mock.someFunc isn't being called:

    MyTest dt;
    Mock<ExternLib> mock;
    Fake(Method(mock, someFunc));
    ExternLib& el = mock.get();
    Verify(Method(mock, someFunc));
    return 0;
    #include "Externlib.h"
    class MyTest {
            int result = 3;
                _manager = new ExternLib();
            virtual void begin() {
                result = _manager->someFunc();
            ExternLib *_manager;

    And I made my own ExternLib implementation (only the bare essential public functions implemented with empty functions):

    #include "Externlib.h"
    ExternLib:: ExternLib() {}
    int ExternLib::someFunc() {
        return 5;
    Dolf Andringa
    ah, wait, this channel is pretty much dead (no questions for over a year).
    I was wondering if I could get some clarification on a use case?
    I am attempting to mock a class dependency using fakeIt but if I create a pointer to the mock's reference an exception occurs in the 'handle' function.
    Wasn't sure what forum to use to get an answer, so I figured I would come to the source.
    I actually figured out my issue. My apologies. Have a great day everyone!