Spike: BDD DSL on top of Swift Testing - #1292
Draft
younata wants to merge 1 commit into
Draft
Conversation
For now, just the bare minimum DSL: describe and it
younata
marked this pull request as draft
July 3, 2024 16:00
Generated by 🚫 Danger |
|
Thanks for giving this a go @younata - Ive started looking at SwiftTesting and can say its definitely a step up from XCTest! Keen to use it. However I really like BDD and the test structure that Quick provides. So i am stuck between a rock and a hard place! I am keen to see where you get with this. Happy to get involved with any beta testing/feedback you may be looking for. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Specprotocol vs.SpecMacroCurrently, Specs are defined by creating a type that conforms to the
Specprotocol: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.Testneeds 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