Discussion:
[Registry] C++ Unit Testing
Felix Berlakovich
2014-06-24 09:21:20 UTC
Permalink
Hi!

I want to ask whether it would be an option to use a C++ Unit Testing Framework for libtools and anything else written in C++ that is not part of the core library. I have no experience with Unit Testing in C++, but in languages like Java or C# using a Unit Testing Framework is pretty common.

I had a quick look at https://code.google.com/p/googletest/ and at least from the documentation it looks very promising (grouping of tests to fixtures, automatic test object creation / destruction for each test, death tests integration with CMake,...).

Are there any concerns or other ideas?

Felix
Markus Raab
2014-06-24 10:04:00 UTC
Permalink
Hello,
Post by Felix Berlakovich
I want to ask whether it would be an option to use a C++ Unit Testing
Framework for libtools and anything else written in C++ that is not part
of the core library. I have no experience with Unit Testing in C++, but in
languages like Java or C# using a Unit Testing Framework is pretty common.
They are very common in C and C++, too.
Post by Felix Berlakovich
I had a quick look at https://code.google.com/p/googletest/ and at least
from the documentation it looks very promising (grouping of tests to
fixtures, automatic test object creation / destruction for each test,
death tests integration with CMake,...).
Can you point me to the death tests integration with CMake? (Or integration
with CMake if you forgot the comma)

I also have a lot of experience with Boost Test Library: Unit Test Framework.
The problem with it is, that the test execution monitor often gets in your way
and Boost::Test is not actively maintained anymore.
Post by Felix Berlakovich
Are there any concerns or other ideas?
They situation is not perfect and it is certainly a good thing to discuss it.
Pro Points:
+ Having the output of current values when an assertion fails in any case
+ No listing of all test cases in main (but instead having test discovery)
+ No more commenting out if you only want to run parts of the test-suite
+ No more typos in test-suite namings
+ xUnit output for jenkins
+ value and type-parameterized tests
+ Mock-Support (not available in gtest?)
+ setup/teardown global+per test
+ death tests

My concerns are:

- It adds another dependency (even though libgtest-dev seems to be very
lightweight)
- It is not ideal to have different frameworks intermixed (C vs. C++
frameworks, but most code is C)
- In the end we have to write a lot of functionality ourselves anyway (e.g.
comparing Keys and KeySets)
- Testsuite execution are already handled by cmake and kdb run-all.
- The selection of tests within a test suite does not play well with ctest.
- Rewriting all current tests to have unified behaviour is a lot of work

best regards,
Markus

Loading...