diff options
author | Sebastian Krämer <sebkraemer@posteo.org> | 2020-12-15 20:24:41 (GMT) |
---|---|---|
committer | Sebastian Krämer <sebkraemer@posteo.org> | 2021-04-15 20:28:41 (GMT) |
commit | c4ed56eb75b1c1f9d1fc7e98f8c9724bb73e2442 (patch) | |
tree | ae17c83107193928dc597d5f633756740e60f939 /docs | |
parent | 8d664b94bebc86a9d3c6272bb41039310c550e58 (diff) | |
download | googletest-c4ed56eb75b1c1f9d1fc7e98f8c9724bb73e2442.zip googletest-c4ed56eb75b1c1f9d1fc7e98f8c9724bb73e2442.tar.gz googletest-c4ed56eb75b1c1f9d1fc7e98f8c9724bb73e2442.tar.bz2 |
Add subsection for GTEST_SKIP documentation
A subsection "Skipping test execution" was added to document GTEST_SKIP
and where it can be used.
relates issue #1544
Diffstat (limited to 'docs')
-rw-r--r-- | docs/advanced.md | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/docs/advanced.md b/docs/advanced.md index ae4d7ee..da7cf07 100644 --- a/docs/advanced.md +++ b/docs/advanced.md @@ -527,6 +527,32 @@ destructor early, possibly leaving your object in a partially-constructed or partially-destructed state! You almost certainly want to `abort` or use `SetUp`/`TearDown` instead. +## Skipping test execution + +Related to pseudo assertions `SUCCEED()` and `FAIL()` you can prevent further test +execution with the `GTEST_SKIP()` macro. + +`GTEST_SKIP` can be used in test cases or in `SetUp()` methods of classes inherited +from either `::testing::Environment` or `::testing::Test`. The latter is a convenient +way to check for preconditions of the system under test during runtime and skip +the test in a meaningful way. + +Based on googletest's own test code: +```c++ +class Fixture : public Test { + protected: + void SetUp() override { + GTEST_SKIP() << "skipping all tests for this fixture"; + } +}; + +TEST_F(Fixture, SkipsOneTest) { + EXPECT_EQ(5, 7); // won't fail, it won't get executed +} +``` + +The informational text is optional. + ## Teaching googletest How to Print Your Values When a test assertion such as `EXPECT_EQ` fails, googletest prints the argument |