mirror of
https://github.com/google/googletest.git
synced 2024-12-26 17:41:03 +08:00
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
This commit is contained in:
parent
8d664b94be
commit
c4ed56eb75
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user