Google Testing library
-
wrote on 10 Dec 2016, 07:42 last edited by Ivan Netskin 12 Oct 2016, 07:43
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:
- 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. - while trying to compile simple test i got tons of errors:
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!
- download and build google test and google mock framework from link above.
-
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.
-
wrote on 12 Dec 2016, 07:35 last edited by
hello, thanks for reply! I'll try and comeback with results
-
wrote on 12 Dec 2016, 12:06 last edited by
it seem this framework does not support dynamic runtime. I've just included sources.
-
Out of curiosity, how did you came to that conclusion ?
-
wrote on 13 Dec 2016, 07:58 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.
2/6