googletest

How to specify multiple exclusion filters in --gtest_filter?

烂漫一生 提交于 2019-12-03 05:21:46
问题 The question is about google-test framework. I want to run all tests excluding some according to multiple exclusion filters, like: --gtest_filter=-ABC.*:-BCD.* 回答1: You group the patterns in the form --gtest_filter=POSTIVE_PATTERNS[-NEGATIVE_PATTERNS] So in this case, you want --gtest_filter=-ABC.*:BCD.* 回答2: See https://blogs.msdn.microsoft.com/taxiahou/2013/07/30/the-usage-of-running-a-subset-of-tests-in-google-test-framework-gtest_filter/. You can find a clear example there. Exclusions are

Setup Google test in CLion

不想你离开。 提交于 2019-12-03 02:38:56
问题 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? 回答1: Create new Project Create a repository in my ClionProjects folder cd ~/ClionProjects mkdir .repo cd .repo Clone the DownloadProject from github git clone https://github.com/Crascit/DownloadProject.git Create a C++ project with a src and test directory Add following files: CMakeLists.txt cmake_minimum_required

Google Test in Visual Studio 2012

我只是一个虾纸丫 提交于 2019-12-03 02:32:59
问题 I am trying to get started with unit testing. I downloaded the latest build of gtest, and extracted it to A:\gtest As the instructions specified, I opened gtest.sln. Visual studio only allows me to open the sln if I agree to update it. Then when I try to build I get a pile of errors: 1>------ Build started: Project: gtest, Configuration: Debug Win32 ------ 1> gtest-all.cc 1>a:\gtest\include\gtest\gtest-printers.h(550): error C2977: 'std::tuple' : too many template arguments 1> b:\program

Can Googletest value-parameterized with multiple, different types of parameters match mbUnit flexibility?

非 Y 不嫁゛ 提交于 2019-12-03 01:51:16
I'd like to write C++ Google tests which can use value-parameterized tests with multiple parameters of different data types, ideally matching the complexity of the following mbUnit tests written in C++/CLI. Note how compact this is, with the [Test] attribute indicating this is a test method and the [Row(...)] attributes defining the values for an instantiation. [Test] [Row("Empty.mdb", "select count(*) from collar", 0)] [Row("SomeCollars.mdb", "select count(*) from collar", 17)] [Row("SomeCollars.mdb", "select count(*) from collar where max_depth=100", 4)] void CountViaDirectSQLCommand(String^

Simplest example of using Google C++ Testing Framework with CMake

99封情书 提交于 2019-12-03 01:43:26
问题 I have a very simple C++ library (one header file, one .cpp file). I want to write unit tests for this project using the Google C++ Testing Framework. Here is the directory structure: ~/project1 | |-- project1.cpp |-- project1.h |-- project1_unittests.cpp \-- CMakeLists.txt I do not plan to write my own main() function. I want to link with gtest_main as mentioned in the primer. What should CMakeLists.txt contain? 回答1: Enable CMake's built-in testing subsystem: # For make-based builds, defines

What is the difference between gtest and gmock?

淺唱寂寞╮ 提交于 2019-12-02 23:26:46
I'm trying to understand the purpose of google-mock , Google's C++ mocking framework . I have already worked with gtest earlier, but still I can't understand what gmock is. Why do we need it? gtest is used for unit testing. What do we need gmock for then, if gmock is required for unit testing ? "Google Mock is not a testing framework itself. Instead, it needs a testing framework for writing tests. Google Mock works seamlessly with Google Test. It comes with a copy of Google Test bundled. Starting with version 1.1.0, you can also use it with any C++ testing framework of your choice. " - Google

How to install GTest on Mac OS X with homebrew?

南楼画角 提交于 2019-12-02 22:33:13
I'm trying to install gtest with my packet manager Home Brew but there is no repository for it. I tried to download gtest frome code.google but i cannt understand how to install it, because cmake and make doesnt solve the problem If you want the latest version without using Homebrew: git clone https://github.com/google/googletest cd googletest mkdir build cd build cmake .. make make install For the question 'Why there is no repository for it?' see related gtest FAQ question . But you can create formula by yourself if you want - see this post for the details (but don't sure if it will work for

How to make google-test classes friends with my classes?

与世无争的帅哥 提交于 2019-12-02 20:09:53
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? Try this (straight from Google Test docs...): FRIEND_TEST(TestCaseName, TestName); For example: // foo.h #include <gtest/gtest_prod.h> // Defines FRIEND_TEST. class Foo { ... private: FRIEND_TEST(FooTest, BarReturnsZeroOnNull); int Bar(void* x); }; // foo_test.cc ... TEST(FooTest, BarReturnsZeroOnNull) { Foo foo; EXPECT_EQ(0, foo.Bar(NULL)); // Uses Foo's private member Bar(). } Ralfizzle I know this is old but I was

Google Unit Test Confusion

帅比萌擦擦* 提交于 2019-12-02 19:10:02
问题 I'm a bit confused about where the unit tests should be. All the documentation leads me to believe that I must create a Test Project. REALLY? With JUnit we just created a Test package (folder) inside our application project and the tests would run with every build. I'm new to C++ and trying to figure out how Google Test works. I've found a lot of really good questions and answers here on SO and Yes I have read the Google Test documentation but I'm still confused about this one thing: Can I

How to specify multiple exclusion filters in --gtest_filter?

元气小坏坏 提交于 2019-12-02 18:40:36
The question is about google-test framework. I want to run all tests excluding some according to multiple exclusion filters, like: --gtest_filter=-ABC.*:-BCD.* You group the patterns in the form --gtest_filter=POSTIVE_PATTERNS[-NEGATIVE_PATTERNS] So in this case, you want --gtest_filter=-ABC.*:BCD.* 来源: https://stackoverflow.com/questions/14018434/how-to-specify-multiple-exclusion-filters-in-gtest-filter