googletest

What are Google Test, Death Tests

╄→尐↘猪︶ㄣ 提交于 2019-11-28 08:58:05
I saw the documentation of that feature is seem pretty major since it's in Google Test overview features and detailed in: https://github.com/google/googletest/blob/master/googletest/docs/advanced.md#death-tests They look like standard assert() but they're part of Google Test, so a xUnit testing framework. Therefore, I wonder what the real usage or advantage of using those death tests are. 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

How can I use Google Test with my project that builds via autotools?

谁说胖子不能爱 提交于 2019-11-28 05:26:09
It seems like there are a few answers that kind-of, sort-of make sense, but that I don't know how to carry out. And I haven't found a comprehensive answer. The First Problem Google Test should not be an installed library, it should be built with the project. (See the FAQ .) As far as I can tell, this means the Google Test libraries are a dependency of my unit tests, and should be built when I run "make check" within my project for the first time. This should build Google Test libraries in some directory. I don't know how to do this. It mentions some autotools script that's deprecated, and I'm

pass method with template arguments to a macro

早过忘川 提交于 2019-11-28 02:48:45
问题 I am unable to use Google Test's ASSERT_THROW() macro in combination with multiple template arguments. Consider that I want to make sure that construction of Matrix<5,1> throws: ASSERT_THROW(Matrix<5,1>(), std::runtime_error); (this example doesn't make a lot of sense, of course this shoud not throw, but it is what stayed after simplifying what I had.) I get this output from MS VC++ 2008: warning C4002: too many actual parameters for macro 'ASSERT_THROW' error C2143: syntax error : missing ',

C++ project organisation (with gtest, cmake and doxygen)

会有一股神秘感。 提交于 2019-11-28 02:31:40
I am new to programming in general so I decided that I would start by making a simple vector class in C++. However I would like to get in to good habits from the start rather than trying to modify my workflow later on. I currently have only two files vector3.hpp and vector3.cpp . This project will slowly start to grow (making it much more of a general linear algebra library) as I become more familiar with everything, so I would like to adopt a "standard" project layout to make life easier later on. So after looking around I have found two ways to go about organizing hpp and cpp files, the

Unable to get hudson to parse JUnit test output XML

萝らか妹 提交于 2019-11-27 21:25:54
问题 EDIT : This issue has been fixed by google in gtest 1.4.0; see the original bug report for more information. I've recently switched to gtest for my C++ testing framework, and one great feature of it which I am presently unable to use is the ability to generate JUnit-style XML test reports, which could then be read in by our hudson build server. The XML output generated by the gtest test suite all looks legit: <?xml version="1.0" encoding="UTF-8"?> <testsuite tests="370" failures="0" disabled=

Linking to multiple .obj for unit testing a console application

旧时模样 提交于 2019-11-27 20:36:15
问题 Having a few issues and hope I can find some help. I have two projects under the same solution in Visual Studio 2012 A bit of background I cam creating a console application which outputs as a .exe this is in one project. In another project I have google test set up to run unit tests on the classes in the console application project. If I was able to compile the main project into a static library there wouldn't be an issue due to could link to the .lib, however this isn't an option. I have

using googletest in eclipse: how?

房东的猫 提交于 2019-11-27 19:49:39
问题 I've downloaded google test, but now I've no idea on how to link it to my project in eclipse. Should I add it as a source folder? Should include it as g++ included library? And how can I run test then? 回答1: 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

Eclipse (CDT) plugin for running tests and browsing report

杀马特。学长 韩版系。学妹 提交于 2019-11-27 17:35:05
问题 Google's answers (hear! hear!) and Eclipse Market Place search results on this topic simply drive me crazy! And apparently the proposed SO answers aren't really helpful either. I'm looking for an Eclipse plugin, that allows me to browse a JUnit report XML compliant unit test report produced from a google test runner. Nice to have features: jump to the source from failure reports run the tests automatically after building. I'm pretty sure a (free) plugin suitable for Eclipse CDT exists, that

Comparison of arrays in google test?

ぐ巨炮叔叔 提交于 2019-11-27 17:29:24
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? vava 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), Pair(2, 20))); //checks that in vector v all the elements are greater than 10 and less than 20 ASSERT

GoogleTest: How to skip a test?

放肆的年华 提交于 2019-11-27 17:25:27
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? Bill 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 ::testing::Test { ... }; // Tests that Bar does Xyz. TEST_F(DISABLED_BarTest, DoesXyz) { ... } Kiril You