Merge pull request #4435 from kaswhy:main

PiperOrigin-RevId: 602385832
Change-Id: I755dae5707e98b6157930a74de90a8e19ef17603
This commit is contained in:
Copybara-Service 2024-01-29 07:50:37 -08:00
commit fc0076ffc4

View File

@ -1004,11 +1004,21 @@ calling the `::testing::AddGlobalTestEnvironment()` function:
Environment* AddGlobalTestEnvironment(Environment* env); Environment* AddGlobalTestEnvironment(Environment* env);
``` ```
Now, when `RUN_ALL_TESTS()` is called, it first calls the `SetUp()` method of Now, when `RUN_ALL_TESTS()` is invoked, it first calls the `SetUp()` method. The
each environment object, then runs the tests if none of the environments tests are then executed, provided that none of the environments have reported
reported fatal failures and `GTEST_SKIP()` was not called. `RUN_ALL_TESTS()` fatal failures and `GTEST_SKIP()` has not been invoked. Finally, `TearDown()` is
always calls `TearDown()` with each environment object, regardless of whether or called.
not the tests were run.
Note that `SetUp()` and `TearDown()` are only invoked if there is at least one
test to be performed. Importantly, `TearDown()` is executed even if the test is
not run due to a fatal failure or `GTEST_SKIP()`.
Calling `SetUp()` and `TearDown()` for each iteration depends on the flag
`gtest_recreate_environments_when_repeating`. `SetUp()` and `TearDown()` are
called for each environment object when the object is recreated for each
iteration. However, if test environments are not recreated for each iteration,
`SetUp()` is called only on the first iteration, and `TearDown()` is called only
on the last iteration.
It's OK to register multiple environment objects. In this suite, their `SetUp()` It's OK to register multiple environment objects. In this suite, their `SetUp()`
will be called in the order they are registered, and their `TearDown()` will be will be called in the order they are registered, and their `TearDown()` will be