Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Google Testing library

    3rd Party Software
    google test google mock
    2
    6
    1671
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Ivan Netskin
      Ivan Netskin last edited by Ivan Netskin

      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

      littleClass.h

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

      main.cpp:

      #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
            .Times(AtLeast(1));
      }
      
      int main(int argc, char *argv[])
      {
          ::testing::GTEST_FLAG(throw_on_failure) = true;
          ::testing::InitGoogleMock(&argc, argv);
      }
      

      Thanks in advance!

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi,

        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.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply Reply Quote 2
        • Ivan Netskin
          Ivan Netskin last edited by

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

          1 Reply Last reply Reply Quote 0
          • Ivan Netskin
            Ivan Netskin last edited by

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

            1 Reply Last reply Reply Quote 0
            • SGaist
              SGaist Lifetime Qt Champion last edited by

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

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply Reply Quote 0
              • Ivan Netskin
                Ivan Netskin last edited by Ivan Netskin

                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.

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post