summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Krämer <sebkraemer@posteo.org>2020-12-15 21:24:41 +0100
committerSebastian Krämer <sebkraemer@posteo.org>2021-04-15 22:28:41 +0200
commitc4ed56eb75b1c1f9d1fc7e98f8c9724bb73e2442 (patch)
treeae17c83107193928dc597d5f633756740e60f939
parent8d664b94bebc86a9d3c6272bb41039310c550e58 (diff)
downloadgoogletest-c4ed56eb75b1c1f9d1fc7e98f8c9724bb73e2442.tar.gz
googletest-c4ed56eb75b1c1f9d1fc7e98f8c9724bb73e2442.zip
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
-rw-r--r--docs/advanced.md26
1 files changed, 26 insertions, 0 deletions
diff --git a/docs/advanced.md b/docs/advanced.md
index ae4d7ee8..da7cf079 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
OpenPOWER on IntegriCloud