googlemock Questions

1

Solved

I am just getting started with Google Mock. The For Dummies is reasonably easy to follow. However, I don't understand why the example has class MockTurtle : public Turtle { public: ... MOCK_M...
Goldeneye asked 11/9, 2015 at 16:3

1

Solved

I am getting some weird compilation errors when I try to mock a function. The compiler complains about something with the copy constructor. Code snippets: class db_key { public: db_key(void) {} ...
Benzocaine asked 8/9, 2015 at 8:22

1

Solved

I'm using Google Mock to specify a compatibility layer to an external API. In the external API, there are multiple ways to do some actions, so I want to specify that at least one (or preferably exa...
Introduce asked 27/8, 2015 at 12:33

2

I just recently discovered gmock and am now in progress of "rethinking the whole programming process as it is", adding unit tests wherever I can. One thing that struck me as weird in the process i...
Nobility asked 18/6, 2015 at 0:16

1

Solved

I've noticed that some projects refer to gtest_main-mdd.lib and others to gmock_maind.lib in my Visual Studio 2010 setup and wanted to know what the difference between the two libs is?
Verbena asked 26/6, 2015 at 5:14

1

I have testing code which does something like EXPECT_CALL(mock, getSomeString()).WillOnce(Return(&testString)); where getSomeString() is returning by reference: std:string& getSomeStrin...
Winged asked 19/5, 2015 at 10:26

2

I'm evaluating the Google Test/Mock as a framework for unit tests of my C code. How can I specify the output string argument for the function I would like to mock? Here I have int get_int_param(c...
Ruddy asked 12/5, 2015 at 9:9

4

I'm using googlemock at work. We often use EXPECT_THROW, EXPECT_NO_THROW etc... My question is how do you make googlemock output the exception details and maybe a stack trace when a function is wr...
Freightage asked 11/7, 2012 at 18:56

1

Solved

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.
Transient asked 28/1, 2015 at 6:13

4

I am pioneering unit testing efforts at my company, and need need to choose a mocking framework to use. I have never used a mocking framework before. We have already chosen Google Test, so us...
Negligent asked 13/5, 2010 at 13:55

3

I often face the problem that mock objects need to be brought in a certain state before the "interesting" part of a test can start. For example, let's say I want to test the following class: stru...
Onega asked 30/3, 2014 at 14:46

1

Solved

The text "callback called" from Callback() prints to console, but gmock fails the test saying that no callback happened. What am I doing wrong? class MyClass { public: MyClass() { }; virtual ~M...
Snood asked 5/11, 2014 at 21:48

1

Solved

Maybe a finesse question, my problem is that if I write: EXPECT_CALL(mock, handleMessage(_)).Times(0); // expectation #1 EXPECT_CALL(mock, handleMessage(Pointee(IsLike(aSpecificMessage)))); // exp...
Haymow asked 26/9, 2014 at 13:31

1

Solved

class Foo { public: int x; int y; void move(void); }; class SuperFoo: public Foo { public: int age; void update(); }; SuperFoo::update(void) { move(); age++; } I'm just starting out wi...
Dioptase asked 25/8, 2014 at 13:43

1

Solved

I have a class I wish to Mock using Google Mock. My class has BOTH non-virtual and virtual methods. I've been reading through the Google Mock ForDummies and the Google Mock CookBook. The examples a...
Felicefelicia asked 1/8, 2014 at 21:32

1

Solved

I am using Google Mock 1.7.0 with Google Test 1.7.0. The problem is when I use NiceMock I get test failures because of unexpected mock function call (which should be ignored by NiceMock as per Goog...
Dunson asked 24/7, 2014 at 1:25

1

Solved

I'm trying to become familiar with Google's mocking framework so I can more easily apply some TDD to my C++ development. I have the following interface: #include <string> class Symbol { pub...
Astrophotography asked 18/5, 2013 at 17:18

1

Solved

I'm writing a test to verify the sequence of calls on an image processing thread. The relevant piece of test code looks like this: Sequence s1, s2; ... EXPECT_CALL(*mMockVideoSource, getFrame()).I...
Come asked 27/5, 2014 at 17:59

1

Solved

I have an interface Itest: class Itest { bool testfunction(vector<int>& v, int& id); } I can mock it with: MOCK_METHOD2(testfunction, bool(vector<int>&, int&)) bu...
Migrant asked 18/4, 2014 at 14:59

2

Solved

I think this question may violate some of the Q&A standards for the site, as the answer(s) I may receive could be regarded as opinion-driven. Nevertheless, here it goes... Suppose we're workin...
Tennies asked 20/1, 2014 at 15:6

2

Solved

I'm using Google Mock, and I'm struggling to mock out C++ system calls (specifically the C++11 chrono functions). I'm know I'm supposed to make an interface, create a class to implement the interf...
Lundquist asked 29/1, 2014 at 7:12

2

Solved

With Google Mock 1.7.0, I have a mock object with a method, and I want to expect it to be called, and in this case the mocked method should throw an exception. ObjectMock object_mock_; EXPECT_CALL...
Carpenter asked 24/1, 2014 at 15:34

1

Solved

I am trying to set an "out" parameter on a mock with SetArgPointee. Here's the code I'm testing: DWORD bodysize = 1024; char body[1024]; HRESULT hr = req->ReadEntityBody(body, bodysize, false, ...
Nodus asked 21/8, 2013 at 16:33

1

Solved

I'm using the Given/When/Then pattern to make test code much clearer. Since I'm writing those tests in C++ I chosed to use Google Test. With tests the pattern is clear, because I do sth like this: ...
Regulator asked 19/8, 2013 at 7:51

2

I have this (not really, is just a simple example): template<class T> T foo() {...} I need to check the result type of the function (here not make any sense, my example is more complex I ...
Oculus asked 6/8, 2011 at 16:34

© 2022 - 2024 — McMap. All rights reserved.