The solution is to declare the function in a *.h, but define it only once in a *.cpp file. Like this:
====Included.h
#ifndef INCLUDED_H_
#define INCLUDED_H_
// This declaration tells anybody who included this header
// that the function exists
bool yes();
#endif
====Included.cpp
#include <Included.h>
// This definition provides the code for that function
bool yes() {
return true;
Ok, thanks guys. I got it working. Because I haven't read how gtest finds the tests without #include'ing them I didn't know if it was doing some magic that messed things up.
Hello all,
Firts time with Gmock framework, I am trying to use simple example of google mock.
Is someone can tell me what I am doing wrong here ?
Thanks.
Here is my code in one file Test.h
class myInterface
{
public:
virtual ~myInterface(){}
virtual bool isReady(void) = 0;
};
class ConcreteImpl : public myInterface
{
public:
bool isReady(){return true;};
};
class MockInterface : public myInterface
{
public:
MOCK_METHOD0(isReady, bool());
};
Here my Test.cpp file using BOOST LIB
class TestDriver
{
public:
TestDriver()
{
BOOST_TEST_MESSAGE("execute TestSetup constructor");
};
~TestDriver()
{
BOOST_TEST_MESSAGE("execute TestSetup destructor");
};
MockInterface mxDriver; // if I comment out this line, it is compiling.
};
when I compile, I am getting an error :
tests\test_src\build/googletest-src/googletest/src/gtest-port.cc:275: multiple definition of `testing::internal::Mutex::Lock()'
CMakeFiles/Test.dir/test_src/DriverTest.cpp.obj:C:tests\test_src\build/googletest-src/googletest/include/gtest/internal/gtest-port.h:2262: first defined here
collect2.exe: error: ld returned 1 exit status