c++unit-testinggoogletestcppunit

Moving parametrized tests under googletest or cppunit


In our C++ project we use separated executable files as unit tests. We use them in the following manner:

test1 -p333 -u512 -t3 -c10000 -m100000000
test1 -p444 -u256 -t1 -c50000 -m20000000
test2 -c555 -v -d2 -t2
test2 -c111 -v -d8 -t4
test3 ...

I.e. we run executable files with different parameters again and again, collect logs and analyze it. At the moment we don't use any testing framework. Sometimes we change the parameters, but rarely.

However we are going to move our tests to Googletest (or CppUnit, we have not decided yet), and I have no idea how can the tests be modified to be used with gtest. For example, I can move test1 and test2 to test fixtures, but I have no idea how to run it with different parameters (without changing the code and recompiling).

Is there any approach to move our parametrized tests under Googletest or Cppunit?


Solution

  • Google Test has support for value parameterized tests. It is described in its wiki. The wiki example explains support only for a simple parameter type, but you can pack multi-value parameters into a struct or a tuple.