Unit testing with C++

I just finished up a internship, and during this internship, I wrote a lot of unit tests for JavaScript using Jest.

I wish I had known earlier in my college days about writing unit tests. It would have made testing my programs a lot easier than manually testing my input all the time instead of having to execute something like this on the command line: ./a.out < testfile_n.

With that being said, I've started to look into some C++ testing frameworks, and one that I've been playing around with is Google's C++ testing framework: https://github.com/google/googletest .

It's nice, but before I start to really get into it, are there some testing frameworks that you guys can recommend me to check out? It seems there are a few out there.
Last edited on
I really like Catch2: https://github.com/catchorg/Catch2
I find that the easiest to use are catch2 and doctest - just 1 header to include.
https://github.com/onqtam/doctest
https://github.com/catchorg/Catch2
Note that recent versions of Visual Studio have built-in integration for:
* Microsoft Unit Testing Framework for C++
* Google Test
* Boost.Test
* CTest -- this is for C code

So knowing one of these might help if you want to work in Windows development.

We use Google Test at work, due to the IDE integration and because it's compatible with Jenkins. It's also got a few features that the alternatives lack.

Regards

Andy

http://www.cplusplus.com/forum/beginner/271815/#msg1171936

https://www.jenkins.io/
https://plugins.jenkins.io/xunit/
Last edited on
I've found Google Test to be good in the past, and obviously it's well integrated with Google Mock, which is also useful.

Where I work now, we use Catch2, which I've found to be easy to use.
Last edited on
Topic archived. No new replies allowed.