Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using googletest to run unit-tests for multiple tested modules at once

I'm working on a large C++ project which contains more than 50 libraries and executables. I am starting to add googletest tests for each of these modules. I read that google recommends putting the tests in an executables and not in libraries to make life easier. Creating a separate executable for each separate components I would get more than 50 test executables and in order to run them all at once I would need to create an external script which would also need to combine their output to a single one. Is that the recommended thing to do?

Or should I create a library for tests of each separate module and link all these libs to a single tests executable? But then running tests for a single module becomes less convinient. I would need to build all the tests and specify to the main test executable through the gtest_filter flag which tests should be executed at this time.

It would really help me to hear how other people do this and what is the best practice here.

Thank you

like image 449
Leonid Koren Avatar asked Nov 23 '13 15:11

Leonid Koren


1 Answers

[...] and in order to run them all at once I would need to create an external script which would also need to combine their output to a single one.

Maybe it's not actually necessary to combine the output into a single file. For example with Jenkins you can specify a wildcard pattern for the Google Test output files.

So if you actually just want to see the Google Test results in Jenkins (or Hudson or whatever CI tool you use), this might be a possible solution:

You would run all of your test executables from a simple script (or even from a Make rule), with parameter --gtest_output=xml: followed by a directory name (ie. ending with a slash). Every test executable will then write an own XML file into that directory, and you can then configure your CI tool to read all files from that directory.

like image 159
oliver Avatar answered Oct 15 '22 10:10

oliver