mirror of
https://github.com/google/googletest.git
synced 2024-12-27 02:01:25 +08:00
Docs: add conditions for calling SetUp and TearDown()
This commit is contained in:
parent
dda72ef321
commit
778badf63a
@ -1004,14 +1004,18 @@ 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.
|
||||||
each environment object, then runs the tests if none of the environments
|
The tests are then executed, provided that none of the environments have reported
|
||||||
reported fatal failures and `GTEST_SKIP()` was not called.
|
fatal failures and GTEST_SKIP() has not been invoked. Finally, TearDown() is called.
|
||||||
|
|
||||||
RUN_ALL_TESTS() calls TearDown() for each environment object when they are recreated
|
Note that SetUp() and TearDown() are only invoked if there is at least one test
|
||||||
for each iteration. However, if the test environments are not recreated for each iteration,
|
to be performed. Importantly, TearDown() is executed even if the test itself
|
||||||
TearDown() is called only on the last iteration.
|
is not run due to exception handling (e.g., fatal failures or if GTEST_SKIP() is invoked).
|
||||||
Additionally, TearDown() is executed regardless of whether the tests were run or not.
|
|
||||||
|
SetUp() and TearDown() are also called for each environment object when they are
|
||||||
|
recreated for each iteration. However, if the 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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user