googletest

What's the difference between gtest.lib and gtest_main.lib?

天涯浪子 提交于 2019-12-18 11:20:53
问题 Google's C++ Test Framework has two output libraries: one is gtest.lib and the other one is gtest_main.lib. According to Nik Reiman's answer on how to setup gtest with Visual Studio, we should link to gtest_main.lib but I'm linking to gtest.lib and the sample test cases that I have are running fine. What's the difference between the two libraries and does it matter which one I link to? 回答1: the only reasonable difference is that gtest_main.lib provides a default implementation of a test

Google Test: Parameterized tests which use an existing test fixture class?

萝らか妹 提交于 2019-12-18 11:13:31
问题 I have a test fixture class which is currently used by many tests. #include <gtest/gtest.h> class MyFixtureTest : public ::testing::Test { void SetUp() { ... } }; I would like to create a parameterized test which also uses all that MyFixtureTest has to offer, without needing to change all my existing tests. How do I do that? I have found similar discussions on the web, but have not fully understood their answers. 回答1: The problem is that for regular tests your fixture has to be derived from

How to clone and integrate external (from git) cmake project into local one

不问归期 提交于 2019-12-18 10:24:45
问题 I faced with a problem when I was trying to use Google Test. There are lot of manuals on how to use ExternalProject_Add for the adding gtest into the project, however most of these describe a method based on downloading zip archive with gtest and build it. As we know gtest is github-hosted and cmake-based project. So I'd like to find native cmake way. If this would be a header-only project, I'd write something like: cmake_minimum_required(VERSION 2.8.8) include(ExternalProject) find_package

Uninteresting mock function call bla() && Expected: to be called at least once bla()?

冷暖自知 提交于 2019-12-18 08:31:30
问题 I've written a small test with a mocked class. When I run it, first I get the warning that an uninteresting mock function was called and then the test fails because the expectation is not met, which is that the mocked function is called at least once. The funny thing is that that function is called as I see that warning message above. Do you have any ideas on this matter? Thank you! Edit: This is my code structure: class Bla { public: Bla(); virtual ~Bla(); virtual float myFunction(); } class

GoogleTest 1.6 with Cygwin 1.7 compile error: 'fileno' was not declared in this scope

偶尔善良 提交于 2019-12-18 03:59:12
问题 GoogleTest 1.6 with Cygwin 1.7: 'fileno' was not declared in this scope Error message when building a simple test on Factorial() function in Eclipse CDT: Invoking: Cygwin C++ Compiler g++ -std=c++0x -DGTEST_OS_CYGWIN=1 -I"E:\source\gtest-1.6.0\include" -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/challenge.d" -MT"src/challenge.d" -o "src/challenge.o" "../src/challenge.cpp" In file included from E:\source\gtest-1.6.0\include/gtest/internal/gtest-internal.h:40:0, from E:\source\gtest-1

How to make GTest build /MDd (instead of /MTd) by default, using CMake?

百般思念 提交于 2019-12-17 20:22:22
问题 I am trying to integrate GTest with CMake as seamlessly as possible. But the default build type for my test projects are /MDd and GTest defaults to /MTd . I am manually changing GTest project properties to emit debug DLL. But every time I make changes to my CMakeLists.txt , GTest defaults back to /MTd . How do I stop this? 回答1: You can define gtest_force_shared_crt to ON before including gtest to achieve this. You can either do this via the command line: cmake . -Dgtest_force_shared_crt=ON or

Jenkins Build Script exits after Google Test execution

天大地大妈咪最大 提交于 2019-12-17 19:42:59
问题 I am building a Qt GUI application via Jenkins. I added 3 build steps: Building the test executable Running the test executable compiling a coverage report with gcovr For some reason, the shell task for running the test executable stops after execution. Even a simple echo does not run after. The tests are written with Google Test and output xUnit XML files, which are analyzed after the build. Some tests start the applications user interface, so I installed the jenkins xvnc plugin to get them

CPack: Exclude INSTALL commands from subdirectory (googletest directory)

元气小坏坏 提交于 2019-12-17 14:50:13
问题 I'm using CMake for a project and googletest for my test cases. Looking around the internet, it seems to be common practise to just copy the googletest source into a subfolder of your repository and include it with "add_subdirectory(googletest)". I did that. Now I'm using CPack to generate debian packages for my project. Unfortunately, the packages generated by CPack install googletest alongside with my project. This is of course not what I want. Looking in the googletest directory, I found

CPack: Exclude INSTALL commands from subdirectory (googletest directory)

[亡魂溺海] 提交于 2019-12-17 14:49:59
问题 I'm using CMake for a project and googletest for my test cases. Looking around the internet, it seems to be common practise to just copy the googletest source into a subfolder of your repository and include it with "add_subdirectory(googletest)". I did that. Now I'm using CPack to generate debian packages for my project. Unfortunately, the packages generated by CPack install googletest alongside with my project. This is of course not what I want. Looking in the googletest directory, I found

undefined reference to `pthread_key_create' (linker error)

百般思念 提交于 2019-12-17 06:54:08
问题 I have downloaded gtest 1.7.0 sources from here: https://code.google.com/p/googletest/downloads/list and build the gtest .a files (lib files) on ubuntu 13.10: Linux ubuntu 3.11.0-15-generic #23-Ubuntu SMP Mon Dec 9 18:17:04 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux and the resulting lib is called: libgtest.a . In my main.cpp file Have: #include <iostream> #include "gtest/gtest.h" int main(){ std::cout << "Test \n"; int argc = 2; char* cp01; char* cp02; char* argv[] = {cp01, cp02}; testing: