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
124e87a3
Commit
124e87a3
authored
Apr 15, 2021
by
Sebastian Krämer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Apply missing suggestions from code review for GTEST_SKIP
Co-authored-by:
Eric Schmidt
<
shibumi@google.com
>
parent
1de97fd1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
11 deletions
+17
-11
advanced.md
docs/advanced.md
+17
-11
No files found.
docs/advanced.md
View file @
124e87a3
...
@@ -529,25 +529,31 @@ partially-destructed state! You almost certainly want to `abort` or use
...
@@ -529,25 +529,31 @@ partially-destructed state! You almost certainly want to `abort` or use
## Skipping test execution
## Skipping test execution
Related to pseudo assertions
`SUCCEED()`
and
`FAIL()`
you can prevent further test
Related to the assertions
`SUCCEED()`
and
`FAIL()`
, you can prevent further test
execution with the
`GTEST_SKIP()`
macro.
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 test cases or in
`SetUp()`
methods of classes inherited
`GTEST_SKIP()`
can be used in individual test cases or in the
`SetUp()`
methods of
from either
`::testing::Environment`
or
`::testing::Test`
. The latter is a convenient
classes derived from either
`::testing::Environment`
or
`::testing::Test`
. For
way to check for preconditions of the system under test during runtime and skip
example:
the test in a meaningful way.
Based on googletest's own test code:
```
c++
```
c++
class
Fixture
:
public
Test
{
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
:
protected
:
void
SetUp
()
override
{
void
SetUp
()
override
{
GTEST_SKIP
()
<<
"
s
kipping all tests for this fixture"
;
GTEST_SKIP
()
<<
"
S
kipping all tests for this fixture"
;
}
}
};
};
TEST_F
(
Fixture
,
SkipsOneTest
)
{
// Tests for SkipFixture won't be executed.
EXPECT_EQ
(
5
,
7
);
// won't fail, it won't get executed
TEST_F
(
SkipFixture
,
SkipsOneTest
)
{
EXPECT_EQ
(
5
,
7
);
// Won't fail
}
}
```
```
...
...
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