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
5142ccd2
Commit
5142ccd2
authored
Mar 24, 2021
by
Abseil Team
Committed by
Dino Radaković
Mar 25, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Googletest export
Update advanced.md PiperOrigin-RevId: 364839958
parent
4595745f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
30 deletions
+34
-30
advanced.md
docs/advanced.md
+34
-30
No files found.
docs/advanced.md
View file @
5142ccd2
...
@@ -813,7 +813,8 @@ initialized from the command-line flag `--gtest_death_test_style`).
...
@@ -813,7 +813,8 @@ initialized from the command-line flag `--gtest_death_test_style`).
consideration to be run - much like the
`threadsafe`
mode on POSIX.
consideration to be run - much like the
`threadsafe`
mode on POSIX.
Other values for the variable are illegal and will cause the death test to fail.
Other values for the variable are illegal and will cause the death test to fail.
Currently, the flag's default value is
**"fast"**
Currently, the flag's default value is
**`"fast"`**
.
1.
the child's exit status satisfies the predicate, and
1.
the child's exit status satisfies the predicate, and
2.
the child's stderr matches the regular expression.
2.
the child's stderr matches the regular expression.
...
@@ -1374,7 +1375,7 @@ The following statement will instantiate tests from the `FooTest` test suite
...
@@ -1374,7 +1375,7 @@ The following statement will instantiate tests from the `FooTest` test suite
each with parameter values
`"meeny"`
,
`"miny"`
, and
`"moe"`
.
each with parameter values
`"meeny"`
,
`"miny"`
, and
`"moe"`
.
```
c++
```
c++
INSTANTIATE_TEST_SUITE_P
(
InstantiationNam
e
,
INSTANTIATE_TEST_SUITE_P
(
MeenyMinyMo
e
,
FooTest
,
FooTest
,
testing
::
Values
(
"meeny"
,
"miny"
,
"moe"
));
testing
::
Values
(
"meeny"
,
"miny"
,
"moe"
));
```
```
...
@@ -1383,51 +1384,54 @@ INSTANTIATE_TEST_SUITE_P(InstantiationName,
...
@@ -1383,51 +1384,54 @@ INSTANTIATE_TEST_SUITE_P(InstantiationName,
NOTE: The code above must be placed at global or namespace scope, not at
NOTE: The code above must be placed at global or namespace scope, not at
function scope.
function scope.
Per default, every
`TEST_P`
without a corresponding
`INSTANTIATE_TEST_SUITE_P`
The first argument to
`INSTANTIATE_TEST_SUITE_P`
is a unique name for the
causes a failing test in test suite
`GoogleTestVerification`
. If you have a test
instantiation of the test suite. The next argument is the name of the test
suite where that omission is not an error, for example it is in a library that
pattern, and the last is the parameter generator.
may be linked in for other reason or where the list of test cases is dynamic and
may be empty, then this check can be suppressed by tagging the test suite:
```
c++
You can instantiate a test pattern more than once, so to distinguish different
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST
(
FooTest
);
instances of the pattern, the instantiation name is added as a prefix to the
```
actual test suite name. Remember to pick unique prefixes for different
instantiations. The tests from the instantiation above will have these names:
To distinguish different instances of the pattern (yes, you can instantiate it
more than once), the first argument to
`INSTANTIATE_TEST_SUITE_P`
is a prefix
that will be added to the actual test suite name. Remember to pick unique
prefixes for different instantiations. The tests from the instantiation above
will have these names:
*
`
InstantiationNam
e/FooTest.DoesBlah/0`
for
`"meeny"`
*
`
MeenyMinyMo
e/FooTest.DoesBlah/0`
for
`"meeny"`
*
`
InstantiationNam
e/FooTest.DoesBlah/1`
for
`"miny"`
*
`
MeenyMinyMo
e/FooTest.DoesBlah/1`
for
`"miny"`
*
`
InstantiationNam
e/FooTest.DoesBlah/2`
for
`"moe"`
*
`
MeenyMinyMo
e/FooTest.DoesBlah/2`
for
`"moe"`
*
`
InstantiationNam
e/FooTest.HasBlahBlah/0`
for
`"meeny"`
*
`
MeenyMinyMo
e/FooTest.HasBlahBlah/0`
for
`"meeny"`
*
`
InstantiationNam
e/FooTest.HasBlahBlah/1`
for
`"miny"`
*
`
MeenyMinyMo
e/FooTest.HasBlahBlah/1`
for
`"miny"`
*
`
InstantiationNam
e/FooTest.HasBlahBlah/2`
for
`"moe"`
*
`
MeenyMinyMo
e/FooTest.HasBlahBlah/2`
for
`"moe"`
You can use these names in
[
`--gtest_filter`
](
#running-a-subset-of-the-tests
)
.
You can use these names in
[
`--gtest_filter`
](
#running-a-subset-of-the-tests
)
.
Th
is statement will instantiate all tests from
`FooTest`
again, each wit
h
Th
e following statement will instantiate all tests from
`FooTest`
again, eac
h
parameter values
`"cat"`
and
`"dog"`
:
with
parameter values
`"cat"`
and
`"dog"`
:
```
c++
```
c++
const
char
*
pets
[]
=
{
"cat"
,
"dog"
};
const
char
*
pets
[]
=
{
"cat"
,
"dog"
};
INSTANTIATE_TEST_SUITE_P
(
AnotherInstantiationName
,
FooTest
,
INSTANTIATE_TEST_SUITE_P
(
Pets
,
FooTest
,
testing
::
ValuesIn
(
pets
));
testing
::
ValuesIn
(
pets
));
```
```
The tests from the instantiation above will have these names:
The tests from the instantiation above will have these names:
*
`
AnotherInstantiationName
/FooTest.DoesBlah/0`
for
`"cat"`
*
`
Pets
/FooTest.DoesBlah/0`
for
`"cat"`
*
`
AnotherInstantiationName
/FooTest.DoesBlah/1`
for
`"dog"`
*
`
Pets
/FooTest.DoesBlah/1`
for
`"dog"`
*
`
AnotherInstantiationName
/FooTest.HasBlahBlah/0`
for
`"cat"`
*
`
Pets
/FooTest.HasBlahBlah/0`
for
`"cat"`
*
`
AnotherInstantiationName
/FooTest.HasBlahBlah/1`
for
`"dog"`
*
`
Pets
/FooTest.HasBlahBlah/1`
for
`"dog"`
Please note that
`INSTANTIATE_TEST_SUITE_P`
will instantiate
*all*
tests in the
Please note that
`INSTANTIATE_TEST_SUITE_P`
will instantiate
*all*
tests in the
given test suite, whether their definitions come before or
*after*
the
given test suite, whether their definitions come before or
*after*
the
`INSTANTIATE_TEST_SUITE_P`
statement.
`INSTANTIATE_TEST_SUITE_P`
statement.
Additionally, by default, every
`TEST_P`
without a corresponding
`INSTANTIATE_TEST_SUITE_P`
causes a failing test in test suite
`GoogleTestVerification`
. If you have a test suite where that omission is not an
error, for example it is in a library that may be linked in for other reasons or
where the list of test cases is dynamic and may be empty, then this check can be
suppressed by tagging the test suite:
```
c++
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST
(
FooTest
);
```
You can see
[
sample7_unittest.cc
]
and
[
sample8_unittest.cc
]
for more examples.
You can see
[
sample7_unittest.cc
]
and
[
sample8_unittest.cc
]
for more examples.
[
sample7_unittest.cc
]:
https://github.com/google/googletest/blob/master/googletest/samples/sample7_unittest.cc
"Parameterized Test example"
[
sample7_unittest.cc
]:
https://github.com/google/googletest/blob/master/googletest/samples/sample7_unittest.cc
"Parameterized Test example"
...
...
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