Suppose I have two/many different tests need to be carried out in gtest in two iteration.
So, how to carryout the same? I tried my approch but it fails.
I wrote,
::testing::GTEST_FLAG(repeat) = 2; //may be 2 or 3 or so on...
switch(i) //int i = 1;
{
case 1:
::testing::GTEST_FLAG(filter) = "*first*:*second*";
i++; break;
case 2:
::testing::GTEST_FLAG(filter) = "*third*:*fourth*";
i++; break;
and so on............
But Google test is taking only the "*first*:*second*" and runs two times.
Please help me. My reqiurement is Gtest should run all the test cases one by one.
e.g first it will execute case 1: then case 2: and so on…
I don’t think you can do this using
::testing::GTEST_FLAG(repeat)However, you could achieve your goal with something like:
I’m not sure how gtest calculates the return value of
RUN_ALL_TESTS()whenGTEST_FLAG(repeat)is used, but heremainwill return0if all tests pass, otherwise it will return the last non-zero value of theRUN_ALL_TESTS()invocations.