2

Suppose I have an interface iface and a couple of its implementations A and B. Now, object of classes A and B are constructed by reading certain files f1,f2,...,fm. That is, there are m objects, and if you consider the 2 implementing classes A and B, there are 2m objects overall. Now, https://github.com/google/googletest/blob/master/docs/advanced.md#how-to-write-value-parameterized-tests is a good starting place for automating the step of feeding the filenames f1,...,fm to the constructors. One then simply uses INSTANTIATE_TEST_CASE_P(MyGroup, BarTest, testing::Values(<some-way-of-getting-filenames>)). On the other hand, there is a concept of Typed-Test: on is able to supply different implementations of an interface, like so

typedef Types<A,B> impls;
INSTANTIATE_TYPED_TEST_CASE_P(MyName,    // Instance name
                              FooTest,             // Test case name
                              impls);  // Type list

Here, FooTest is defined as

template<class T>
class FooTest : public ::testing::Test {
//...
}

again according to the documentation/sample at https://github.com/abseil/googletest/blob/master/googletest/samples/sample6_unittest.cc, whereas BarTest is defined as

class BarTest : public ::testing::Test, public ::testing::TestWithParam<const char*>

Now I can see that what I need is a combination of INSTANTIATE_TEST_CASE_P and INSTANTIATE_TYPED_TEST_CASE_P, over a class FooBarTest that derives from testing::Test, TestWithParam, and also has a template parameter T. The question is, is this possible? Is there such a macros?

DerKasper
  • 167
  • 2
  • 11
Ilonpilaaja
  • 1,169
  • 2
  • 15
  • 26
  • 1
    This post will help: https://stackoverflow.com/questions/8507385/google-test-is-there-a-way-to-combine-a-test-which-is-both-type-parameterized-a – lrm29 Dec 09 '18 at 20:31
  • Possible duplicate of [Google Test: Is there a way to combine a test which is both type parameterized and value parameterized?](https://stackoverflow.com/questions/8507385/google-test-is-there-a-way-to-combine-a-test-which-is-both-type-parameterized-a) – Mike Kinghan Dec 10 '18 at 07:26

0 Answers0