How to run tests and debug Google Test project in VS Code?

Start with a clean directory: /home/user/Desktop/projects/cpp/ # your project lives here Add your cmake file(CMakeLists.txt), your source files, and test file. The directory now looks like this: └─cpp/ ├─ CMakeLists.txt ├─ myfunctions.h └─ mytests.cpp Clone and add googletest to this directory: └─cpp/ ├─ googletest/ ├─ CMakeLists.txt ├─ myfunctions.h └─ mytests.cpp Open your CMakeLists.txt and enter … Read more

What are Google Test, Death Tests

The assertion is there to confirm that a function would bring about program termination if it were executed in the current process (the details explains that the death test is invoked from a subprocess which allows the tests to continue despite the death). This is useful because some code may guarantee program termination / abortion … Read more

google mock – can I call EXPECT_CALL multiple times on same mock object?

Yes, you can call EXPECT_CALL on the same mock object multiple times. As long as you assure that all EXPECT_CALL were called before the mocked methods were actually used. Otherwise your test will rely on undefined behavior. From ForDummies: Important note: gMock requires expectations to be set before the mock functions are called, otherwise the … Read more

using googletest in eclipse: how?

Using Riga’s excellent answer, here is a summary of how I got it to work: Created a new C++ project in Eclipse (I chose Executable > Empty Project) Downloaded googletest 1.5.0, untarred, and ran ./scripts/fuse_gtest_files.py . <project-dir>/contrib Back in Eclipse, excluded the contrib directory from the Release build configuration, and added <project-dir>/contrib to the include … Read more

tech