#Unit testing tools / frameworks for cpp
14 messages · Page 1 of 1 (latest)
When your question is answered use !solved or the button below to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
I have never used one but from what I have red, people use google test?
I don't have that much experience with different ones, but my understanding is that it's like with build systems: they all suck, so might as well use the most popular one, which is gtest
Catch2 is fine (until you do multithreading inside your tests).
Google test, in comparison, had worse comparison macros (did not desugar REQUIRES(a == b); into
Expected: a == b
With a:
Foobar
And b:
foobar
)
and also requires unreasonable amounts of boiler plate (write a class that overrides setup and teardown for each set of tests).
Catch2 just lets you write tests.
That's silly, gtest requires no such thing. This is all you have to do:
TEST(Group, TestName) {
EXPECT_EQ(strlen("Hello", 5));
}
It's true that you have to use the correct comparison macro, EXPECT_TRUE, EXPECT_EQ, EXPECT_GT, EXPECT_LT, EXPECT_GE, EXPECT_LE, EXPECT_STREQ, ...
I guess I was doing it wrong then.
When all you have is a hammer...
What does require quite a bit of boilerplate is Google Mock. In my job number N-1, we required 90% decision coverage from tests. This came at a cost: twice as many lines of test code than payload code.
Anyway, I recommend looking through https://github.com/catchorg/Catch2/blob/devel/docs/tutorial.md#top and see if that seems reasonable.
Catch is certainly more modern
ty for the advise, I'll look into catch2 and gtest