Spike: BDD DSL on top of Swift Testing #1292
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Swift Testing is the new, mostly open source testing framework for Swift. It provides a pytest-style approach to testing, with native support for nested tests, like what Quick and other BDD-style frameworks provide.
This PR is an attempt to create a Quick-Style DSL on top of Swift Testing. This work explicitly does not support Objective-C, using resultbuilders to build its DSL.
This PR, for now, adds a new library target, QuickTesting, just to provide a separate space for these new type names. I intend to later merge this new target back in to the main Quick target.
Design Decisions
Spec
protocol vs.Spec
MacroCurrently, Specs are defined by creating a type that conforms to the
Spec
protocol:I can easily reduce the level of indentation by one by using a macro instead:
But, I'm not doing that (yet?). This is because macros (currently) come with a number of drawbacks:
Most importantly, they're rather daunting to implement. Using a protocol is something I'm very familiar with, while macros are still new to me.
But, gosh, I'd love to remove as much horizontal indentations as I can.
Issues
Testing.Test
needs to have a public initializer so that we can generate tests Add a public initializer for Testing.Test swiftlang/swift-testing#521Previous Work
I previously tried to implement Quick's Async support using resultbuilders, which was quite the learning experience: #1194