Googletest (GTest) allows you to disable individual tests by adding
DISABLED_
prefix to the test name.
What about parametrized tests -- how do I disable those? Adding the prefix to the test name does not disable them.
For example, how do I disable the example test provided by GTest documentation:
class FooTest : public ::testing::TestWithParam<const char*> {
// You can implement all the usual fixture class members here.
// To access the test parameter, call GetParam() from class
// TestWithParam<T>.
};
TEST_P(FooTest, HasBlahBlah) {
...
}
INSTANTIATE_TEST_CASE_P(InstantiationName,
FooTest,
::testing::Values("meeny", "miny", "moe"));
The docs for Google Test 1.7 suggest: If you have a broken test that you cannot fix right away, you can add the DISABLED_ prefix to its name. This will exclude it from execution. This is better than commenting out the code or using #if 0 , as disabled tests are still compiled (and thus won't rot).
If you need one or more test suites to be skipped during a project run, you can disable them. To do this: Right-click the desired test suites and select Disable Test Suite.
INSTANTIATE_TEST_CASE_P( LeapYearTests, LeapYearParameterizedTestFixture, ::testing::Values( 1, 711, 1989, 2013 )); Here we call the INSTANTIATE_TEST_CASE_P macro with first with a unique name for the instantiation of the test suite. This name can distinguish between multiple instantiations.
TEST_P() is useful when you want to write tests with a parameter. Instead of writing multiple tests with different values of the parameter, you can write one test using TEST_P() which uses GetParam() and can be instantiated using INSTANTIATE_TEST_SUITE_P() . Example test. Follow this answer to receive notifications.
You need to add the
DISABLED_
prefix to the instantiation name, like this:
INSTANTIATE_TEST_CASE_P(DISABLED_InstantiationName,
FooTest,
::testing::Values("meeny", "miny", "moe"));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With