How to send custom message in Google C++ Testing Framework?
The gtest macros return a stream for outputting diagnostic messages when a test fails. EXPECT_TRUE(false) << “diagnostic message”;
The gtest macros return a stream for outputting diagnostic messages when a test fails. EXPECT_TRUE(false) << “diagnostic message”;
You group the patterns in the form –gtest_filter=POSTIVE_PATTERNS[-NEGATIVE_PATTERNS] So in this case, you want –gtest_filter=-ABC.*:BCD.*
C++ build systems are a bit of a black art and the older the project the more weird stuff you can find so it is not surprising that a lot of questions come up. I’ll try to walk through the questions one by one and mention some general things regarding building C++ libraries. Separating headers … Read more
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. This is better than commenting out the code or using #if 0, as disabled tests are still compiled (and thus won’t … Read more
The solution involved putting the gtest source directory as a subdirectory of your project. I’ve included the working CMakeLists.txt below if it is helpful to anyone. cmake_minimum_required(VERSION 2.6) project(basic_test) ################################ # GTest ################################ ADD_SUBDIRECTORY (gtest-1.6.0) enable_testing() include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR}) ################################ # Unit Tests ################################ # Add test cpp file add_executable( runUnitTests testgtest.cpp ) # Link test … Read more
You could use advanced options to run Google tests. To run only some unit tests you could use –gtest_filter=Test_Cases1* command line option with value that accepts the * and ? wildcards for matching with multiple tests. I think it will solve your problem. UPD: Well, the question was how to run specific test cases. Integration … Read more
A new player is Google Test (also known as Google C++ Testing Framework) which is pretty nice though. #include <gtest/gtest.h> TEST(MyTestSuitName, MyTestCaseName) { int actual = 1; EXPECT_GT(actual, 0); EXPECT_EQ(1, actual) << “Should be equal to one”; } Main features: Portable Fatal and non-fatal assertions Easy assertions informative messages: ASSERT_EQ(5, Foo(i)) << ” where i … Read more