-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Docs: add conditions for calling SetUp() and TearDown() #4435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
docs/advanced.md
Outdated
| reported fatal failures and `GTEST_SKIP()` was not called. `RUN_ALL_TESTS()` | ||
| always calls `TearDown()` with each environment object, regardless of whether or | ||
| not the tests were run. | ||
| Now, when RUN_ALL_TESTS() is invoked, it first calls the SetUp() method. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we keep the "of each environment object" part?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think including that part might make it confusing. The comments in the code linked above correspond to the 'of each environment object' part.
docs/advanced.md
Outdated
| 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 itself | ||
| is not run due to exception handling (e.g., fatal failures or if GTEST_SKIP() is invoked). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of "exception handling", can we more accurately say if "the test is not run due to a fatal failure or GTEST_SKIP()"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll make that change!
docs/advanced.md
Outdated
| is not run due to exception handling (e.g., fatal failures or if GTEST_SKIP() is invoked). | ||
| 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a link or at least mention gtest_recreate_environments_when_repeating?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I'll add a link.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well.. I noticed that the Testing Reference doesn't include gtest_recreate_environments_when_repeating, so I just decided to mention it.
#3840 (comment)
In the implementation, TearDown() is executed for each environment object when they are recreated for each iteration. If they are not recreated, it is only called on the last iteration.
before change (docs)
Now, when RUN_ALL_TESTS() is called, it first calls the SetUp() method of each environment object, then runs the tests if none of the environments reported fatal failures and GTEST_SKIP() was not called. RUN_ALL_TESTS() always calls TearDown() with each environment object, regardless of whether or not the tests were run.
after change (docs)
Now, when RUN_ALL_TESTS() is invoked, it first calls the SetUp() method. The tests are then executed, provided that none of the environments have reported fatal failures and GTEST_SKIP() has not been invoked. Finally, TearDown() is called.
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 itself is not run due to exception handling (e.g., fatal failures or if GTEST_SKIP() is invoked).
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.