I have a unit test that I need to run for 200 possible combinations of data. (The production implementation has the data to be tested in configuration files. I know how to mock these values). I prefer nit writing separate test case for each combination and to use some way of looping through the data. Is there some such direct way using Google test for C++?
Share
You can make use of gtest’s Value-parameterized tests for this.
Using this in conjunction with the
Combine(g1, g2, ..., gN)generator sounds like your best bet.The following example populates 2
vectors, one ofints and the other ofstrings, then with just a single test fixture, creates tests for every combination of available values in the 2vectors: