Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. 3rd Party Software
  4. Google Testing library
QtWS25 Last Chance

Google Testing library

Scheduled Pinned Locked Moved 3rd Party Software
google testgoogle mock
6 Posts 2 Posters 2.2k Views
  • 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.
  • I Offline
    I Offline
    Ivan Netskin
    wrote on 10 Dec 2016, 07:42 last edited by Ivan Netskin 12 Oct 2016, 07:43
    #1

    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
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 10 Dec 2016, 21:17 last edited by
      #2

      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
      2
      • I Offline
        I Offline
        Ivan Netskin
        wrote on 12 Dec 2016, 07:35 last edited by
        #3

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

        1 Reply Last reply
        0
        • I Offline
          I Offline
          Ivan Netskin
          wrote on 12 Dec 2016, 12:06 last edited by
          #4

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

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 12 Dec 2016, 16:11 last edited by
            #5

            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
            0
            • I Offline
              I Offline
              Ivan Netskin
              wrote on 13 Dec 2016, 07:58 last edited by Ivan Netskin
              #6

              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
              0

              2/6

              10 Dec 2016, 21:17

              4 unread
              • Login

              • Login or register to search.
              2 out of 6
              • First post
                2/6
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved