-
-
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
Conditional QuickConfiguration / Extensible example flags #800
Comments
FilterFlags is not for such usecases, but for the test filtering feature (focused tests, pending tests, excluded tests). So
that is no go. |
we use example flags to filter some of our specs.
|
We simply do testable import Quick to get access to flags. Would be nice to use a public API. |
Hey there! 👋🏼 I'm a new maintainer for this project and I'm trying to get the next release out ASAP and also clean up old issues and old PRs. I'm closing all issues that no longer seem relevant or are very old / stale. This does not mean this issue is necessarily being rejected. If you are still interested in contributing the changes specified in this issue, please comment to request it be reopened. We appreciate you opening this issue and acknowledge the time and effort you put in to contribute! You're awesome. 💯 However, we are all volunteers here with limited capacity working for free. Unfortunately, that means we must close out stale issues and PRs to move the project forward in a reasonable way. We apologize for the inconvenience and appreciate your understanding! 😎 ✌🏼 |
I'd like to request a (better) way to create a configuration that applies to only certain examples.
I have some examples that require a Core Data stack to be setup. I have some examples that don't. I have some examples that require not just a Core Data stack, but a stack that is persisted on-disk due to a Core Data bug with aggregate operations (for most examples, an in-memory stack works great, and it's a fine default).
So, I'm working with a few different configurations:
With
XCTestCase
, I solved this with aCoreDataTestCase
subclass. I could opt-in toCoreData
by changing the test case to extendCoreDataTestCase
. Additionally, I could override aninMemoryStore
variable I crated to control behavior of the stack duringsetup
.I had a hard time porting this logic to Quick. My first attempt was to create a
CoreDataQuickSpec
that extendedQuickSpec
that did the same sorts of things (overridingsetup
to set up the core data stack, etc). It worked, but it didn't feel right (e.g. it wasn't idiomatic).My next approach was to create a
CoreDataQuickConfiguration
. This mostly worked, but I wasn't able to separate the different configurations on a per-example basis. That is, with this approach, every single example had a Core Data stack setup via the configuration and it had to be always set up on disk (because that worked around the Core Data bug across all examples). In the interest of making my specs as fast as possible, my configuration was working against me.To solve this, I tried to tap into flags, e.g.:
... but I quickly ran into a problem trying to read those flags from within the configuration.
ExampleMetaData
->Example
does not exposefilterFlags
at the level of visibility I needed within myQuickConfiguration
subclass. Also, I'm not sure thatfilterFlags
would be the same semantically here as perhapsconfigurationFlags
or even perhaps anexampleParameters
would be.I'm coming to Quick with experience in Ruby/RSpec. In RSpec, there's user-defined metadata available: https://relishapp.com/rspec/rspec-core/docs/metadata/user-defined-metadata
Using metadata, I can easily extend my examples, e.g.:
.. and then create an RSpec configuration that leverages my user-defined extension:
What I eventually settled on feels like I'm sort of on the right path, but it also feels like a workaround. I decided to just add Ruby-like symbols into the describe string, and use substring matching in the
QuickConfiguration
subclass to alter behavior. Brittle, yes. But, it works for now at least.For example:
... which lets me write my examples like this:
I could go further down this path and perhaps write some parsing logic in my configuration to try to pull out a parameter after my fake Ruby-like symbols, but so far I haven't had a need for it... and I'd rather try to modify Quick to add this behavior vs. continuing down an obvious workaround path.
Now... all of that said... is this something that Quick already supports and I am just missing the right way to achieve this? Has this already been discussed and I didn't have the right keywords to search for to find the discussion? If so, I'm happy to submit a PR to update the documentation if someone points me in the right direction.
Otherwise, I'd enjoy seeing this feature implemented. I suspect this is something that could be perhaps easily supported by either exposing
filterFlags
to the configuration, or creating a newparameters
[String: Any]
dictionary or something for each example, visible to the configuration throughExampleMetadata
to take the appropriate action...The text was updated successfully, but these errors were encountered: