googlemock Questions

4

Solved

I'm trying to understand the purpose of google-mock, Google's C++ mocking framework. I have already worked with gtest earlier, but still I can't understand what gmock is. Why do we need it? gtest...
Lollar asked 4/12, 2012 at 5:1

3

Solved

I'm using gmock to mock my dependencies in legacy code. One of the class have a method with 11 parameters. When I tried to use MOCK_METHOD11_WITH_CALLTYPE to mock it, I found this macro doesn't exi...
Blithering asked 21/3, 2013 at 3:53

1

Solved

TL;DR: You can use GMock to add mocking capability to your Microsoft native c++ unit tests. See my answer below for details. I want to start adding mocks to my existing set of native unit tests....
Depressomotor asked 27/3, 2019 at 18:41

1

Solved

I have created a simple C++ test project with one mocking class: #include <gtest/gtest.h> #include <gmock/gmock.h> class TestMock { public: MOCK_CONST_METHOD0(Method1, void()); }; T...
Repudiate asked 3/9, 2017 at 16:19

1

I have read Can Google Mock a method with a smart pointer return type? but it did not really give much of an answer. I have a factory that returns unique_ptr instances. Returning unique_ptr is a r...
Foy asked 31/7, 2015 at 10:59

2

I'm comparing GoogleMock vs FakeIt for writing unit tests. I like FakeIt over GoogleMock because I'm from Java background and FakeIt sticks close to Mockito/JMock syntax which make using the librar...
Inositol asked 10/11, 2015 at 21:3

3

I am starting to use googlemock with googletest but am getting an SEH exception that I can't figure out. The error message is: unknown file: error: SEH exception with code 0xc0000005 thrown in th...
Mordy asked 11/4, 2013 at 15:47

2

I try to implement uni tests for our C++ legacy code base. I read through Michael Feathers "Working effectively with legacy code" and got some idea how to achieve my goal. I use GooleTest/GooleMock...
Fitzpatrick asked 3/9, 2018 at 15:30

1

Solved

I would like to test the method of my system, whose return value partially depends on the return value of the call to some kind of connection interface. In most cases I would like the IConnection t...
Twi asked 3/7, 2018 at 16:26

4

Solved

I'm mocking a C++ class which has 2 overloaded functions using Google Mock and VS2010: #include "stdafx.h" #include "gmock/gmock.h" #include "A.h" class MockA : public A { public: // ... MOCK_...
Musteline asked 9/1, 2011 at 11:33

1

Solved

Let's assume that there is Bar object which uses a Foo object. The ownership is exclusive, so Bar gets Foo as a std::unique_ptr in its constructor. I would like to test Bar with Google Test framewo...
Terpsichorean asked 23/5, 2018 at 18:54

2

Solved

I've run into an issue while attempting to start using Google Mocks - for some reason it can't tell the call I'm specifying in the EXPECT_CALL macro, even though the types are consistent. I want to...
Illuminometer asked 13/2, 2013 at 0:56

2

Solved

In Mockito we can specify multiple returns like (taken from here): //you can set different behavior for consecutive method calls. //Last stubbing (e.g: thenReturn("foo")) determines the behavior ...
Ouster asked 26/10, 2015 at 20:49

1

Solved

I would like to use some existing matchers in other matcher. I know about the MatcherInterface solution but I was wondering can I use matchers which were defined by MATCHER_P. If found this solutio...
Pleading asked 26/2, 2018 at 12:8

2

Solved

Consider the case where a certain mocked function is expected to be called several times, each time with a different value in a certain parameter. I would like to validate that the function was ind...
Rondi asked 21/4, 2011 at 11:5

1

I inject a dependency in some class. This class stores the dependency with an std::unique_ptr and is therefore the only owner of the object. What is the right way to mock a method in this dependen...
Exasperation asked 24/12, 2017 at 1:18

3

Solved

I have an issue with the google mock EXPECT_CALL macro. The following code gives compilation error on the EXPECT_CALL Statement: error C2660: 'testing::Eq' : function does not take 1 arguments ...
Bawbee asked 17/9, 2013 at 3:54

2

Solved

I have a mock method. When it is called, I'd like it to call another function before calling its normal behavior. Something like : EXPECT_CALL(*my_obj, MockedMethod(_,_,_,_,_,_)) .WillOnce(DoAll(...
Chromoplast asked 15/1, 2015 at 12:35

0

I'm doing a google mock test for my code and I get this error when I run the test. Specifically, when I comment out the default constructor of my mock then the error vanishes. I want to understand ...
Zora asked 4/10, 2017 at 7:10

1

Solved

I have a class which accepts a pointer to another class and has a method read(): class B: { public: ...... void read(char * str); ...... }; class A { public: A(B *bobj):b(bobj); B* b; void read (...
Wot asked 7/9, 2017 at 9:28

2

Solved

Given a large project with thousands of tests, some of which take multiple minutes to complete. When executed sequentially, the whole set of test takes more than an hour to finish. The testing time...
Continuative asked 2/7, 2014 at 10:30

1

Solved

I started with testing GoogleMock (1.8.0 release) on Windows. I wanted to show an example that it is not thread safe. After proving that successfully, I wanted to show that the same test runs fine ...
Harney asked 25/6, 2017 at 19:51

2

How to use gmock to mock a template method (not a template class) for a class? Example a class like this, I want to mock this class, and this template method.. class A{ public: template<EnumTyp...
Standush asked 11/5, 2017 at 9:57

1

Solved

Sorry if the title isn't clear. I have a virtual base class: class FileSystemInterface { public: virtual ~FileSystemInterface() {}; virtual void save(std::string file_content) = 0; }; My moc...
Latton asked 17/5, 2017 at 15:21

1

Solved

I am new to googlemock (and StackOverflow). I got a problem when using MOCK_METHODn in googlemock and I believe this function is widely used. Here is what I did. I have an abstract class Foo with v...
Magdalen asked 5/5, 2017 at 4:23

© 2022 - 2024 — McMap. All rights reserved.