-
-
Notifications
You must be signed in to change notification settings - Fork 906
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
Add aroundEach #1132
Add aroundEach #1132
Conversation
Replicated non-check for proper context from beforeEach and afterEach
FYI, the one CI failure is Danger giving an error that appears to be unrelated to these changes:
|
Thanks so much @pcantrell ! 💯 Does this also address #989 or no? |
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.
Looks like just a few linter errors. Let's address those, then we can merge.
Yes. Danger cannot run on forks because GitHub can't be bothered to implement a CI system that works. |
No, #989 is a separate discussion about a breaking change to the execution order of This PR preserves Quick’s existing Detailed discussion here: #820 (comment)
Does any CI system work, really? 🧐 |
got it 👍🏼
lol |
@pcantrell there are conflicts from #1133 -- very sorry about that! 😊 |
After this merges I'll cut the 5.0 release! 😄 |
Should be gtg, assuming remaining tests pass on CI. Sorry about the big merge commits. There have been enough intervening changes that it doesn’t rebase cleanly anymore! |
No worries! I'll squash and merge this one. |
@pcantrell invited you to the org as a maintainer! 😄 |
Yay slash oh no! |
This is a reopening of #820, brought up to date with the latest main. Here is an updated summary; full historical discussion is in the original PR. I’d sure love to get this merged before it hits the 4-year mark!
This PR adds an
aroundEach
decoration, which accepts the individual example as a callback:See the similar features in Rspec and JUnit.
Motivation
There are a few test setup/cleanup scenarios the existing
beforeEach
/afterEach
don’t handle, or don’t handle well.Some test decorations can’t split into a separate
beforeEach
andafterEach
. The original motivation for addingaroundEach
is Siesta checking for leaks in specs. To do this, it needs to wrap each spec in its own autorelease pool, then verify that objects are no longer retained after the pool is drained:I’d like to pull out both the
autoreleasepool
block andcheckObjectsNoLongerRetained()
so they’re not repeated in each spec. (The two are tightly coupled, and it makes sense to factor them out together.) This is not possible withbeforeEach
/afterEach
, but witharoundEach
it is:Other methods that take a closure/block present a similar problem: XCTest’s
measure
, for example.Even in cases where it is possible to split the decoration into
beforeEach
andafterEach
, it’s not always desirable. Grouping tightly coupled before and after behavior in a singlearoundEach
can help ensure proper nesting of operations.Implementation notes
This PR works to preserve Quick’s somewhat illogical before/after hook execution order. (See #989.)
This PR reimplements before and after hooks using the new feature. Internally, there is now only around. This appears to work; all existing specs still pass!
Merge checklist