DEV Community

Matteus Silva
Matteus Silva

Posted on

What do you use for testing c/c++ apps?

Hello there!

I'm starting a new learning journey about quality assurance of C/C++ applications.
What framework do you use for testing c/c++ applications? Why?

Thanks in advance, community :)

Top comments (11)

Collapse
 
malwarebo profile image
Irfan

Add this one to your arsenal of tools.
godbolt.org/

Collapse
 
silvamatteus profile image
Matteus Silva

Really useful.
I wish I knew this when I took compilers.

Collapse
 
vimmer9 profile image
Damir Franusic

Excellent name "godbolt" :-D

Collapse
 
malwarebo profile image
Irfan

It is the last name of the creator "Matt Godbolt".

Thread Thread
 
vimmer9 profile image
Damir Franusic

The Bolt of God :-D

Collapse
 
hilaberger92 profile image
Hila Berger

Gtest is the optimal test framework for c\c++, it has everything you need and for free.
For mocking I use Isolator++, it is not cheap but very powerful and unique:\
It can mock almost any type of behavior in any kind of code.

I find accessing private modules in your code and faking static methods super important and that makes my life so much easier.
TBH i haven't found any other tool that is as much powerful as that one, all mocking frameworks these days demand refactoring of your code and that always causes tons of new errors.

Good Luck!

Collapse
 
silvamatteus profile image
Matteus Silva

Thank you! I also found Google Mock. Do you have any experience (good or bad) about GMock?

Collapse
 
bosley profile image
Bosley

I use cpputest for my personal projects to ensure that every time that I build, any new changes made to the code won't cause something to happen unexpectedly.

cpputest.github.io/

For everything debugging I will launch QT creator and attach my process to it. QT creator's debugger is awesome, and your project doesn't have to be a QT one or involve any of the QT libraries to use it.

doc.qt.io/qtcreator/creator-debugg...

Collapse
 
silvamatteus profile image
Matteus Silva

Curiously, these for "really bad days" are the only I'm used to =P, thanks to the CTFs.

Collapse
 
vimmer9 profile image
Damir Franusic

I have used Valgrind but these days I mostly use -fsanitize gcc/clang switches since they don't cause such a major slowdown and memory consumption.

Great article. I spent the last 8 years doing only c++ network programming. Then after thinking things through, I thought to myself that this is overly complex for what I'm doing and OOP is something I can live without. Also, I can easily replicate it with function pointers which I also use in C++ anyway.

This was just a quick intro, you should stick with C++ if you like it; you wrote a great post about it anyway. Now, here's the reason I'm writing this comment; there's an alternative to Valgrind which you could consider using once you get more acquainted with C++. Valgrind incurrs 20x slowdon or was 10x I don't rememeber honestly, but it can get quite slow and eat up a huge amount of memory. The other alternative that doesn't cause any noticeable slowdown are gcc/clang fsanitize methods

gcc -ggdb -o a.out a.cpp \
-fsanitize=address \
-fno-omit-frame-pointer

When I first started coding in C++ I also usw Valgrind; not even sure if fsanitize methods were available back then.

Happy programming and congrats on this great post.

DF

Collapse
 
shaswata56 profile image
Shaswata Das

My brain, vim, gcc, stdlib and gdb is enough for me through lifetime.