您应该能够通过使用继承创建第二个测试类来做到这一点。
这类似于两个常见问题条目的方法:
我可以从另一个派生测试夹具吗?
我有几个测试用例共享相同的逻辑......
在下面的代码大纲中,我将类型分成两个不相交的集合。
template <typename T>
class FooTest : public testing::Test
{
//class body
};
// TestTypes only contains some of the types as before
// in this example, floating point types are tested only with FooTest.
typedef ::testing::Types<float, double, /*, and few more*/> TestTypes;
TYPED_TEST_CASE(FooTest, TestTypes);
TYPED_TEST(FooTest, test1)
{
//...
}
// Optional, but could allow you to reuse test constructor
// and SetUp/TearDown functions
template <typename T>
class ExtendedFooTest : public FooTest<T>
{}
// And integral types are given extended tests
typedef ::testing::Types<int, unsigned int, and few more*/> ExtendedFooTypes;
TYPED_TEST_CASE(FooTest, ExtendedFooTypes); // repeat the tests above
TYPED_TEST_CASE(ExtendedFooTest, ExtendedFooTypes); // Plus add new tests.
TYPED_TEST(ExtendedFooTest, test2)
{
//...;
}