#Unit testing tools / frameworks for cpp

14 messages · Page 1 of 1 (latest)

raven dirge
#

Hoping to starting using some unit testing framework or tools for a project I'm currently working on. Would appreciate any suggestions / advice on where to start looking

sand raftBOT
#

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.

barren cave
#

I have never used one but from what I have red, people use google test?

tawdry star
#

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

jaunty vapor
#

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.

formal reef
#

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, ...

jaunty vapor
#

I guess I was doing it wrong then.

formal reef
#

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.

jaunty vapor
formal reef
#

Catch is certainly more modern

raven dirge
#

ty for the advise, I'll look into catch2 and gtest