You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Other than in examples, there is no clear definition of what a "section" is in UT. The closest to a definition is the following:
I'd like to nest my tests, though and share setup/tear-down. With lambdas used to represents tests/sections we can easily achieve that.
"Sharing" setup and tear-down, as I understand it, means that each "should" has to execute the setup steps before it executes its steps, For example, if I have a section with three lines of setup and five "should" lambdas, if I set a breakpoint at one of those three lines, I should break five times, each time before executing one of the "should" lambdas. That is not what I see in the debugger.
I believe the example below the quote above appears to "work" because the first "should" lambda takes its argument by value, even though mut() may allow modification (to the copy). However, if the setup steps involve side-effects (e.g., external streams) or the tests modify by reference the objects instantiated in the setup, then this not what I would consider "sharing of setup and teardown".
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Other than in examples, there is no clear definition of what a "section" is in UT. The closest to a definition is the following:
"Sharing" setup and tear-down, as I understand it, means that each "should" has to execute the setup steps before it executes its steps, For example, if I have a section with three lines of setup and five "should" lambdas, if I set a breakpoint at one of those three lines, I should break five times, each time before executing one of the "should" lambdas. That is not what I see in the debugger.
I believe the example below the quote above appears to "work" because the first "should" lambda takes its argument by value, even though mut() may allow modification (to the copy). However, if the setup steps involve side-effects (e.g., external streams) or the tests modify by reference the objects instantiated in the setup, then this not what I would consider "sharing of setup and teardown".
Beta Was this translation helpful? Give feedback.
All reactions