FAQ Database Discussion Community


Setting custom value to void pointer in gmock

c++,c,unit-testing,pointers,googlemock
I am using Google Mock to unit test my C implementation. For one of my mock function the out parameter is defined as void pointer. The mock function is given below: MOCK_METHOD3(file_read, int(const char *file_name, const char *type_name, void *data_p)); According to How to set a value to void *...

How can I use GoogleMock in jenkins?

c++,gcc,jenkins,centos,googlemock
I installed Jenkins on a CentOS vm. Now I want to run unittests (google test) with mocks (google mock). I tried installing the frameworks like described here. (On my lubuntu machine everything runs without a problem using these steps) When I try to build: g++ -O2 -pthread -Werror -Wall -o...

Mocking free function

c++,unit-testing,tdd,googlemock
I am stuck in a problem and can't seem to find the solution. I am using VS2005 SP1 for compiling the code. I have a global function: A* foo(); I have a mock class class MockA : public A { public: MOCK_METHOD0 (bar, bool()); ... }; In the sources, it...

Why the compiler does not recognize Google Mock wildcard?

c++,googletest,googlemock
When I try to use: ON_CALL(mock, foo(_)) Compilation error is thrown: Error 1 error C2065: '_' : undeclared identifier I am using visual studio 2012....

How to test method in google test, using std::function?

c++,unit-testing,testing,googletest,googlemock
I would like to test method "methodToTest" in class A: typedef std::function F_global; struct A { F_global m_F_global; A(F_global m_F_global) : p_F_global(m_F_global) {} void methodToTest() { m_F_global(5); } }; I have got a mock class: class RunMock { public: MOCK_METHOD1(run, void (int)); }; Below I have got a test case:...

How to check with Google Test zero or one function call?

c++,unit-testing,googletest,googlemock
I want to write a test, that invokes 2 functions in different threads, and I expect that depending on which function will work first happpens this: EXPECT_CALL(foo, bar(arg_1)); or this: EXPECT_CALL(foo, bar(arg_1)).RetiresOnSaturation(); EXPECT_CALL(foo, bar(arg_2)).RetiresOnSaturation(); EXPECT_CALL(foo, bar(arg_1)).RetiresOnSaturation(); exactly in this order. What is the easiest way to do it? I'm pretty...

Automatically Generate Google Mock Methods?

c++,methods,googletest,googlemock
I'm fairly new to C++ and Unit testing and I'm learning to use Google Mock and Google Test right now to test some code that I'm working with. Instead of writing all of the Google Mock methods manually, is there a way to point Google Mock to your class and...

How to compare special fields in google mock?

c++,testing,googletest,googlemock
I have got question connected with google test. I would like to ask if while inducing "EXPECT_CALL(*A, some_method(mes1));" in test case there is possiblity to compare fields included in mes1 class. struct Mes { int a; }; //short section of test case: Mes mes1 = Mes(); EXPECT_CALL(*A, some_method(mes1)); I would...

GoogleMock: Expect either of two method calls

c++,testing,mocking,googlemock
I have a class Foo that references multiple other objects of type IBar. The class has a method fun that needs to invoke method frob on at least one of those IBars. I want to write a test with mocked IBars that verifies this requirement. I'm using GoogleMock. I currently...