Giter Club home page Giter Club logo

easymock's Introduction

EasyMock, based on CppFreeMock

Forked from cppfreemock, based on gmock, can mock global function, member (virtual/nonvirtual) function, class static function without change source code.

What you have to do:

  • include easymock.h into you test source file
  • if using googlemock please make sure that you have included the easymock.h after #include<gmock/gmock.h>
  • create a mocker to a desired function using CREATE_MOCKER(&...) macro
  • on the created mocker do a expect call using gmock EXPECT_CALL(...) macro
  • after calling method or function under test make sure that you've cleared the mocker created using DISABLE_MOCKER(mocker) or CLEAR_MOCKER(mocker)

Hello world example:

string func() {
    return "Non mocked.";
}

TEST(HelloWorld, First) {
    EXPECT_CALL(*CREATE_MOCKER(func), MOCK_FUNCTION()).Times(Exactly(1)).WillOnce(Return("Hello world."));
    EXPECT_EQ("Hello world.", func());
}

For more info check the wiki

easymock's People

Contributors

gzc9047 avatar vesavlad avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.