summaryrefslogtreecommitdiffstats
path: root/googletest/test
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2020-01-14 05:41:46 (GMT)
committervslashg <gfalcon@google.com>2020-01-16 18:55:45 (GMT)
commit0b024bd91a14a77a7e7d6072ccd88e09c86ddeaa (patch)
tree78c316c82a0281387d5b1959eb6cafcd68848c0b /googletest/test
parented16134fb31382fd41e8fe513a0e9e940d04cd31 (diff)
downloadgoogletest-0b024bd91a14a77a7e7d6072ccd88e09c86ddeaa.zip
googletest-0b024bd91a14a77a7e7d6072ccd88e09c86ddeaa.tar.gz
googletest-0b024bd91a14a77a7e7d6072ccd88e09c86ddeaa.tar.bz2
Googletest export
Add GTEST_ALLOW_UNINSTANTIATED_PARAMTERIZED_TEST to mark a paramaterized test as allowed to be un-instantiated. This allows test suites, that are defined in libraries and, for other reasons, get linked in (which should probably be avoided, but isn't always possible) to be marked as allowed to go uninstantiated. This can also be used to grandfather existing issues and expedite adoption of the checks with regards to new cases before they can be fixed. PiperOrigin-RevId: 289581573
Diffstat (limited to 'googletest/test')
-rw-r--r--googletest/test/googletest-output-test-golden-lin.txt4
-rw-r--r--googletest/test/googletest-param-test-test.cc11
2 files changed, 15 insertions, 0 deletions
diff --git a/googletest/test/googletest-output-test-golden-lin.txt b/googletest/test/googletest-output-test-golden-lin.txt
index c1db004..7249081 100644
--- a/googletest/test/googletest-output-test-golden-lin.txt
+++ b/googletest/test/googletest-output-test-golden-lin.txt
@@ -987,6 +987,10 @@ Stack trace: (omitted)
Paramaterized test suite DetectNotInstantiatedTest is defined via TEST_P, but never instantiated. None of the test cases will run. Either no INSTANTIATE_TEST_SUITE_P is provided or the only ones provided expand to nothing.
Ideally, TEST_P definitions should only ever be included as part of binaries that intend to use them. (As opposed to, for example, being placed in a library that may be linked in to get other utilities.)
+
+To suppress this error for this test suite, insert the following line (in a non-header) in the namespace it is defined in:
+
+GTEST_ALLOW_UNINSTANTIATED_PARAMTERIZED_TEST(DetectNotInstantiatedTest);
[ OK ] GoogleTestVerification.UninstantiatedParamaterizedTestSuite<DetectNotInstantiatedTest>
[ RUN ] GoogleTestVerification.UninstantiatedTypeParamaterizedTestSuite<DetectNotInstantiatedTypesTest>
Type paramaterized test suite DetectNotInstantiatedTypesTest is defined via REGISTER_TYPED_TEST_SUITE_P, but never instantiated via INSTANTIATE_TYPED_TEST_SUITE_P. None of the test cases will run.
diff --git a/googletest/test/googletest-param-test-test.cc b/googletest/test/googletest-param-test-test.cc
index f92eb31..b3b8140 100644
--- a/googletest/test/googletest-param-test-test.cc
+++ b/googletest/test/googletest-param-test-test.cc
@@ -1077,6 +1077,17 @@ class NotUsedTest : public testing::TestWithParam<int> {};
template <typename T>
class NotUsedTypeTest : public testing::Test {};
TYPED_TEST_SUITE_P(NotUsedTypeTest);
+
+// Used but not instantiated, this would fail. but...
+class NotInstantiatedTest : public testing::TestWithParam<int> {};
+// ... we mark is as allowed.
+GTEST_ALLOW_UNINSTANTIATED_PARAMTERIZED_TEST(NotInstantiatedTest);
+
+TEST_P(NotInstantiatedTest, Used) { }
+
+using OtherName = NotInstantiatedTest;
+GTEST_ALLOW_UNINSTANTIATED_PARAMTERIZED_TEST(OtherName);
+TEST_P(OtherName, Used) { }
} // namespace works_here
int main(int argc, char **argv) {