Important: Please read the Qt Code of Conduct -

Google Testing library

  • Hello, i'm trying to make work the Google Testing Framework but i'm stuck at this point.

    Following these steps u will get my errors:

    1. download and build google test and google mock framework from link above.
      2)I've configured and generated via CMAKE using Microsoft Visual C++ Compiler 12.0 (x86)
      3)build it with visual studio 2013.
    2. while trying to compile simple test i got tons of errors:
      alt text


    #ifndef LITTLECLASS_H
    #define LITTLECLASS_H
    #include "gmock/gmock.h"
    class LittleClass
        enum Type{
        LittleClass(int type):m_editable(false){
        bool m_editable;
    class Drawer{
        Drawer(const LittleClass *lc){
            if (lc->m_editable)
        virtual void draw()=0;
    class MockDrawer:public Drawer{
        MockDrawer(const LittleClass *lc):Drawer(lc){}
        MOCK_METHOD0(draw, void());
    #endif // LITTLECLASS_H


    #include "gmock/gmock.h"
    #include "gtest/gtest.h"
    #include "littleclass.h"
    using ::testing::AtLeast;
    TEST(PainterTest, CanDrawSomething) {
      LittleClass lc(LittleClass::Editable);
      MockDrawer mymock(&lc);                          // #2
      EXPECT_CALL(mymock, draw())              // #3
    int main(int argc, char *argv[])
        ::testing::GTEST_FLAG(throw_on_failure) = true;
        ::testing::InitGoogleMock(&argc, argv);

    Thanks in advance!

  • Lifetime Qt Champion


    You have likely built the Google Testing Framework with the static VS runtime. Qt uses the dynamic runtime. You should rebuild the Google Testing Framework to also use the dynamic runtime.

  • hello, thanks for reply! I'll try and comeback with results

  • it seem this framework does not support dynamic runtime. I've just included sources.

  • Lifetime Qt Champion

    Out of curiosity, how did you came to that conclusion ?

  • u won't get .lib along with .dll when compiling the framework with MD option due to there is no
    exported class at all in the code. At least with msvc.

Log in to reply