I have a test fixture class which is currently used by many tests.
#include <gtest/gtest.h>
class MyFixtureTest : public ::testing::Test {
void SetUp() { ... }
};
I would like to create a parameterized test which also uses all that MyFixtureTest has to offer, without needing to change all my existing tests.
How do I do that?
I have found similar discussions on the web, but have not fully understood their answers.
This question is now answered in the Google Test documentation (the answer from VladLosev is technically correct, but perhaps slightly more work)
Specifically, when you want to add parameters to a pre-existing fixture class, you can do
class MyFixtureTest : public ::testing::Test {
...
};
class MyParamFixtureTest : public MyFixtureTest,
public ::testing::WithParamInterface<MyParameterType> {
...
};
TEST_P(MyParamFixtureTest, MyTestName) { ... }