Skip to content

Commit fc0076f

Browse files
Merge pull request #4435 from kaswhy:main
PiperOrigin-RevId: 602385832 Change-Id: I755dae5707e98b6157930a74de90a8e19ef17603
2 parents 6a59382 + 1cab76c commit fc0076f

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

docs/advanced.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,11 +1004,21 @@ calling the `::testing::AddGlobalTestEnvironment()` function:
10041004
Environment* AddGlobalTestEnvironment(Environment* env);
10051005
```
10061006
1007-
Now, when `RUN_ALL_TESTS()` is called, it first calls the `SetUp()` method of
1008-
each environment object, then runs the tests if none of the environments
1009-
reported fatal failures and `GTEST_SKIP()` was not called. `RUN_ALL_TESTS()`
1010-
always calls `TearDown()` with each environment object, regardless of whether or
1011-
not the tests were run.
1007+
Now, when `RUN_ALL_TESTS()` is invoked, it first calls the `SetUp()` method. The
1008+
tests are then executed, provided that none of the environments have reported
1009+
fatal failures and `GTEST_SKIP()` has not been invoked. Finally, `TearDown()` is
1010+
called.
1011+
1012+
Note that `SetUp()` and `TearDown()` are only invoked if there is at least one
1013+
test to be performed. Importantly, `TearDown()` is executed even if the test is
1014+
not run due to a fatal failure or `GTEST_SKIP()`.
1015+
1016+
Calling `SetUp()` and `TearDown()` for each iteration depends on the flag
1017+
`gtest_recreate_environments_when_repeating`. `SetUp()` and `TearDown()` are
1018+
called for each environment object when the object is recreated for each
1019+
iteration. However, if test environments are not recreated for each iteration,
1020+
`SetUp()` is called only on the first iteration, and `TearDown()` is called only
1021+
on the last iteration.
10121022
10131023
It's OK to register multiple environment objects. In this suite, their `SetUp()`
10141024
will be called in the order they are registered, and their `TearDown()` will be

0 commit comments

Comments
 (0)