googletest

Data-driven unit tests with google test

大兔子大兔子 提交于 2019-11-26 21:37:13
问题 I am currently writing unit tests for an embedded application using googles unit test framework. Now my boss got upset that the data I test with (i.e. the values with which I call methods of the class under test) is hard wired in the tests. He requests to have this data read-in from a file. His argument is that it would thus be easier to add another test for a corner case that was previously forgotten. I am not that experienced with unit tests but so far that was not how I did it. So I tried

Comparison of arrays in google test?

非 Y 不嫁゛ 提交于 2019-11-26 18:58:45
问题 I am looking to compare two arrays in google test. In UnitTest++ this is done through CHECK_ARRAY_EQUAL. How do you do it in google test? 回答1: I would really suggest looking at Google C++ Mocking Framework. Even if you don't want to mock anything, it allows you to write rather complicated assertions with ease. For example //checks that vector v is {5, 10, 15} ASSERT_THAT(v, ElementsAre(5, 10, 15)); //checks that map m only have elements 1 => 10, 2 => 20 ASSERT_THAT(m, ElementsAre(Pair(1, 10),

GoogleTest: How to skip a test?

与世无争的帅哥 提交于 2019-11-26 18:58:22
问题 Using Google Test 1.6 (Windows 7, Visual Studio C++). How can I turn off a given test? (aka how can I prevent a test from running). Is there anything I can do besides commenting out the whole test? 回答1: The docs for Google Test 1.7 suggest: "If you have a broken test that you cannot fix right away, you can add the DISABLED_ prefix to its name. This will exclude it from execution." Examples: // Tests that Foo does Abc. TEST(FooTest, DISABLED_DoesAbc) { ... } class DISABLED_BarTest : public :

Comparison of C++ unit test frameworks [closed]

时光总嘲笑我的痴心妄想 提交于 2019-11-26 12:33:58
I know there are already a few questions regarding recommendations for C++ unit test frameworks, but all the answers did not help as they just recommend one of the frameworks but do not provide any information about a (feature) comparison. I think the most interesting frameworks are CppUnit, Boost and the new Google testing framework. Has anybody done any comparison yet? Sam Saffron See this question for some discussion. They recommend the articles: Exploring the C++ Unit Testing Framework Jungle , By Noel Llopis. And the more recent: C++ Test Unit Frameworks I have not found an article that

CMake + GoogleTest

老子叫甜甜 提交于 2019-11-26 11:10:02
I just downloaded googletest, generated its makefile with CMake and built it. Now, I need to use it in my testing project. With CMake, I have been advised not pointing to gtest libraries directly (using include _directories or link_directories ) but use find_package() instead. The problem is, there is no install target for the gtest makefile generated. I cannot understand how find_package(GTest REQUIRED) could work without some kind of installation. Also, putting the gtest folder as a subfolder in my project is not possible. Thanks for any help. This is an unusual case; most projects specify

How to set up Google C++ Testing Framework (gtest) with Visual Studio 2005

走远了吗. 提交于 2019-11-26 11:04:41
It is not documented on the web site and people seem to be having problems setting up the framework. Can someone please show a step-by-step introduction for a sample project setup? What Arlaharen said was basically right, except he left out the part which explains your linker errors. First of all, you need to build your application without the CRT as a runtime library. You should always do this anyways, as it really simplifies distribution of your application. If you don't do this, then all of your users need the Visual C++ Runtime Library installed, and those who do not will complain about

How to set up googleTest as a shared library on Linux

北城以北 提交于 2019-11-26 10:07:25
问题 Debian does not provide any precompiled packages for gTest anymore. They suggest you integrate the framework into your project\'s makefile. But I want to keep my makefile clean. How do I set up gTest like the former versions (<1.6.0), so that I can link against the library? 回答1: Before you start make sure your have read and understood this note from Google! This tutorial makes using gtest easy, but may introduce nasty bugs. 1. Get the googletest framework wget https://github.com/google

How to start working with GTest and CMake

我怕爱的太早我们不能终老 提交于 2019-11-26 07:54:35
问题 I have recently been sold on using CMake for compiling my C++ projects, and would now like to start writing some unit tests for my code. I have decided to use the Google Test utility to help with this, but require some help in getting started. All day I have been reading various guides and examples include the Primer, an introduction at IBM and some questions on SO (here and here) as well as other sources I\'ve lost track of. I realise there\'s plenty out there but somehow I am still having

Comparison of C++ unit test frameworks [closed]

不羁岁月 提交于 2019-11-26 02:59:32
问题 I know there are already a few questions regarding recommendations for C++ unit test frameworks, but all the answers did not help as they just recommend one of the frameworks but do not provide any information about a (feature) comparison. I think the most interesting frameworks are CppUnit, Boost and the new Google testing framework. Has anybody done any comparison yet? 回答1: See this question for some discussion. They recommend the articles: Exploring the C++ Unit Testing Framework Jungle,