googletest Questions

4

Solved

I want to test a template class with gtest. I read about TYPED_TESTs in gtest manual and looked at the official example (samples\sample6_unittest.cc) they reference. This template from the example ...
Henshaw asked 1/4, 2015 at 3:1

3

Solved

I’m using Google Test to test my C++ project. Some cases, however, require access to argc and argv to load the required data. In the main() method, when initializing, argc and argv are passed to t...
Floatation asked 10/3, 2011 at 14:18

5

Solved

I heard there is a possibility to enable google-test TestCase classes friends to my classes, thus enabling tests to access my private/protected members. How to accomplish that?
Madgemadhouse asked 7/3, 2010 at 13:22

6

Solved

I'm surprised that Google C++ Testing Framework does not explicitly support checking for memory leaks. There is, however, a workaround for Microsoft Visual C++, but what about Linux? If memory man...
Brachiopod asked 20/3, 2015 at 20:3

4

I am building and running unit tests built with googletest inside a cmake project with ctest enabled I run the tests with "ctest -VV" but the test output does not color the "red" and "green" [ ...
Recuperate asked 13/12, 2015 at 16:45

2

I am generating a .sln with CMake. I want to use Google Test and use that kind of code for adding a new tests: add_executable(my_test test/my_test.cpp) target_link_libraries(my_test gtest gmock_ma...
Lissotrichous asked 12/10, 2016 at 18:45

4

Solved

After building my testfile, xxxxtest, with gtest can I pass a parameter when running the test, e.g. ./xxxxtest 100. I want to control my test function using the parameter, but I do not know how to ...
Colony asked 29/2, 2012 at 9:42

2

Solved

I recently discovered the Failures into Break-Points - option from googletest using the command line option gtest_break_on_failure or by defining the GTEST_BREAK_ON_FAILURE environment variable. I...
Florance asked 3/4, 2013 at 7:48

3

Solved

How do I test that a function won't produce a segmentation fault? Here what I know right now, I can do: EXPECT_DEATH(foo(nullParameter)) In side the function, a segmentation fault is produce wh...
Bernard asked 30/11, 2017 at 22:0

4

Solved

I have been sitting online for hours already trying to setup Google test on Clion in Linux but have not been able to find anything. Can someone guide me with setting this up please?
Decasyllabic asked 10/11, 2015 at 19:56

3

Solved

I am using various xunit tests for years (starting from cppunit in early 2000s). In all cases it was very easy to set a break point on failure: there was a function that indicated detected failure:...
Blondie asked 18/3, 2019 at 22:11

4

I am using gtest to write unit tests for my application. I also have ctest that runs all executables added by add_test CMake command. Is it possible to pass gtest variables through ctest when test ...
Quickstep asked 31/10, 2017 at 12:25

4

Solved

While ASSERT_* macros cause termination of test case, EXPECT_* macros continue its evaluation. I would like to know which is the criteria to decide whether to use one or the other.
Irrawaddy asked 2/4, 2010 at 6:21

3

Solved

I'm having a rather strange problem telling googletest to print a certain class the way I want using PrintTo. The class is a very simple 2D point, it is in a namespace and the PrintTo function is i...
Tantalum asked 10/7, 2014 at 9:55

4

Solved

I'm confused regarding inheritance when googletesting. I have a class A that has protected attributes. If I want to access those i have to extend that class, but at the same time i also need to ext...
Olag asked 13/10, 2014 at 9:51

4

Solved

So I'm working on creating my first unit tests. I'm using Google Test, the version that is currently built into Visual Studio 2017. This is an attempt at a proof of concept, so super simple. I hav...
Amory asked 7/5, 2018 at 20:41

11

I am writing a test using GoogleTest for the following class and I am getting the above error. class Base { // Other Functions; CSig objSig[50]; } The Class CSig is as follows: class CSig { ...
Peanuts asked 31/10, 2012 at 12:11

7

Solved

I'm new in google test C++ framework. It's quite easy to use but I'm wondering how to separate the cases into multiple test files. What is the best way? Include the .cpp files directly is an optio...
Hanzelin asked 16/9, 2011 at 11:24

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

3

Solved

Consider that I have two strings: std::string s1 = "ab"; std::string s2 = "cd"; and I want to check (e.g. using EXPECT_EQ) if some given std::string str is equal either to s1 or s2. If gtest's...
Lithophyte asked 7/8, 2018 at 16:30

2

Solved

I am working on a procedural C/C++ project. The public interface consists of 4 functions, each with fairly complex tasks. There are helper functions declared in the same cpp file, in an unnamed nam...
Marvismarwin asked 9/2, 2013 at 7:15

2

Solved

I am using gtest to create unit tests to my c++ program. In my tests I have to write a lot of checks like this: ASSERT_TRUE(myObject.IsValid()); EXPECT_EQ(myObject.GetSomeAttribute(), expectedValu...
Perdita asked 21/7, 2017 at 14:27

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

3

I'm using Google Test for C++ and trying to set it up on my linux machine. My make file has the following code: CC=g++ CFLAGS=-I $(GOOGLETESTDIR)/include -L $(GOOGLETESTDIR)/lib -lgtest -lpthread...
Specify asked 5/3, 2015 at 3:10

7

Solved

I have a C++ project in Visual Studio, and have added another project exclusively for testing. Both of these projects are EXEs (console apps). So how do I use the first project inside the second? ...
Steen asked 15/4, 2014 at 15:33

© 2022 - 2024 — McMap. All rights reserved.