googlemock Questions
4
Solved
I am a fairly new software developer currently working adding unit tests to an existing C++ project that started years ago. Due to a non-technical reason, I'm not allowed to modify any existing cod...
Demavend asked 26/2, 2010 at 4:46
2
Solved
I'm looking for some #define which can stop test-case execution if first test failed
TEST_F(TestInitializer, 1st-test) {
Initiator.call();
EXPECT_CALL(mock_obj, onAction(false)).Times(AtLeast(0...
Davedaveda asked 9/5, 2018 at 14:21
4
In the quickstart of google test (https://google.github.io/googletest/quickstart-cmake.html) I found the following code to download the google test dependencies from Github:
cmake_minimum_required(...
Bop asked 5/7, 2022 at 11:33
2
Solved
I have researched a lot about gtest/gmock but none of them gave me the right answer. I'm new to C++ so any help would be really appreciated.
Ofris asked 29/10, 2019 at 2:29
3
Solved
I am trying to mock a templated method.
Here is the class containing the method to mock :
class myClass
{
public:
virtual ~myClass() {}
template<typename T>
void myMethod(T param);
}
...
Chiou asked 6/8, 2010 at 17:11
6
Solved
I don't understand the difference between ON_CALL and EXPECT_CALL when using it to
specify the default action.
So far I noticed/learned there are two ways to adjust the default action of a mock:
...
Quillan asked 18/12, 2012 at 12:52
3
Solved
I'm attempting to integrate googlemock into my tests. I had already successfully built and run tests on googletest, and now am trying to incrementally add the gmock functionality into the tests as ...
Meshwork asked 24/5, 2012 at 16:13
7
I am new to gmock, so I want to know how can I stub simple C function called in a function under test for Unit Testing.
Example:
int func(int a)
{
boolean find;
// Some code
find = func_1();
...
Elroy asked 13/8, 2015 at 13:2
4
Solved
Introduction
I am writing tests on Eigen matrices using Google's testing framework Google-Mock, as already discussed in another question.
With the following code I was able to add a custom Matche...
Clotilda asked 5/8, 2014 at 19:41
1
I'm new to Google test and I'm trying to write a unit test for a function that returns void and takes no arguments but the function has an if condition which checks on structure values, and I need ...
Nonprofit asked 2/9, 2022 at 10:29
2
Solved
Given:
#include "gmock/gmock.h"
#include <string>
using namespace testing; // tsk, tsk
// -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
struct Mockable {
virtual std::st...
Rudich asked 2/10, 2014 at 8:20
2
Solved
I'm trying to get a working googletest test that compares two vectors. For this I'm using google mock with its matchers but I get a C3861 error saying "ContainerEq identifier not found" a...
Hive asked 9/9, 2012 at 15:42
1
Solved
Background:
I'm mocking a hardware i2c transmit function, and trying to match on an array passed into it. This is in an embedded context, hence the c-style arrays and lack of STL containers.
Trying...
Psychotechnology asked 12/6, 2022 at 12:26
3
Solved
I want to mock a method that returns a complex datatyp
class aClass
{
public:
virtual const QMap<QString, QString> aMethod() const;
}
class MockaClass : public aClass
{
public:
MOCK_CONST...
Cacomistle asked 18/4, 2012 at 10:25
3
Solved
I just started working on unit testing (using BOOST framework for testing, but for mocks I have to use Google Mock) and I have this situation :
class A
{
static int Method1(int a, int b){return a...
Andromada asked 20/1, 2012 at 13:44
4
Solved
How to mock a method with optional parameter in Google Mock?
For example:
class A
{
public:
void set_enable( bool enabled = true );
};
class MockA : public A
{
MOCK_METHOD1( set_enable, void(...
Quart asked 21/7, 2016 at 9:30
4
I have a data structure which is being notified to a listener. Among its many variables, it has an optional double which represents an angle:
struct Data
{
// ...other data fields
std::optional&l...
Lock asked 25/8, 2020 at 10:20
3
I am new to Google's test products and trying them out with some signal processing code. I am trying to assert that to floating point arrays are equal to within some bounds, using google mock as su...
Pelagias asked 27/2, 2015 at 15:17
1
When trying to mock a function with google test i still get a warning that I miss a "override"
MOCK_METHOD(bool, functionName, (), (const override));
The warning I get states
xxx.h:31:2...
Boulevard asked 1/7, 2021 at 10:57
4
Solved
Just getting into Unit Testing with C++. It looks like I will need to write several stub classes as I go along. My understanding is there is a difference between Mocks and Stubs. Basically it seems...
Calliecalligraphy asked 14/6, 2011 at 23:32
1
One of the benefits of dependency injection is ease of testing, as mocked classes can be injected. Clazz takes raw pointer for that purpose and moves it to unique pointer, to signal that it owns In...
Fullerton asked 23/7, 2018 at 7:43
4
I am using VS2005, and C++ for unit testing using google mock.
I had a global free function in unit testing, and I used the following code to mock free function:
NiceMock <MockA> mockObj;
...
Marx asked 12/2, 2015 at 11:7
4
Solved
I want to test that in case of some fail no method will be called on a mock object, using google mock.
So the code would be something like:
auto mockObj = new MockObj;
EXPECT_NO_METHOD_CALL(mockObj...
Amygdala asked 27/12, 2011 at 19:1
2
I am trying to mock out some code that returns information by writing to one of the references passed to the function as a parameter. Is there a good way to mock this behavior such that I can have ...
Autecology asked 2/10, 2015 at 16:8
5
Solved
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 {
pub...
Amine asked 8/2, 2015 at 9:2
1 Next >
© 2022 - 2024 — McMap. All rights reserved.