Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
googletest
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
googletest
Commits
11da093e
Commit
11da093e
authored
Apr 26, 2021
by
Derek Mauro
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3174 from sebkraemer:issue-15644
PiperOrigin-RevId: 369696657
parents
23ef2955
124e87a3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
0 deletions
+32
-0
advanced.md
docs/advanced.md
+32
-0
No files found.
docs/advanced.md
View file @
11da093e
...
@@ -527,6 +527,38 @@ destructor early, possibly leaving your object in a partially-constructed or
...
@@ -527,6 +527,38 @@ destructor early, possibly leaving your object in a partially-constructed or
partially-destructed state! You almost certainly want to
`abort`
or use
partially-destructed state! You almost certainly want to
`abort`
or use
`SetUp`
/
`TearDown`
instead.
`SetUp`
/
`TearDown`
instead.
## Skipping test execution
Related to the assertions
`SUCCEED()`
and
`FAIL()`
, you can prevent further test
execution at runtime with the
`GTEST_SKIP()`
macro. This is useful when you need
to check for preconditions of the system under test during runtime and skip
tests in a meaningful way.
`GTEST_SKIP()`
can be used in individual test cases or in the
`SetUp()`
methods
of classes derived from either
`::testing::Environment`
or
`::testing::Test`
.
For example:
```
c++
TEST
(
SkipTest
,
DoesSkip
)
{
GTEST_SKIP
()
<<
"Skipping single test"
;
EXPECT_EQ
(
0
,
1
);
// Won't fail; it won't be executed
}
class
SkipFixture
:
public
::
testing
::
Test
{
protected
:
void
SetUp
()
override
{
GTEST_SKIP
()
<<
"Skipping all tests for this fixture"
;
}
};
// Tests for SkipFixture won't be executed.
TEST_F
(
SkipFixture
,
SkipsOneTest
)
{
EXPECT_EQ
(
5
,
7
);
// Won't fail
}
```
As with assertion macros, you can stream a custom message into
`GTEST_SKIP()`
.
## Teaching googletest How to Print Your Values
## Teaching googletest How to Print Your Values
When a test assertion such as
`EXPECT_EQ`
fails, googletest prints the argument
When a test assertion such as
`EXPECT_EQ`
fails, googletest prints the argument
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment