-
Notifications
You must be signed in to change notification settings - Fork 140
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
Swift support for the Cedar test runner #367
Conversation
There may be some dependency here on sorting out our Travis situation (#345), as Swift 2 is a requirement for some of this stuff to work properly. |
Here's a full example of using this in a test target mixing Objective-C and Swift specs with Nimble matchers: https://github.com/briancroom/TastesOfCocoa/tree/master/CedarWithNimble |
This is truly awesome! I had wondered if it would be possible to conditionally compile in the C++ features of Cedar, but couldn't find a way to make it work because of the strict rule of the umbrella header importing each public header. Conditionally bringing in the contents of the header though is quite clever. 🏆 |
To make progress on getting CI fixed up for this I'm intending to introduce an opt-out compile-time flag that can be included in rake's xcodebuild invocation to exclude the swift spec for older Xcode versions. |
If there's anything we can do to help out, please let us know. There's a bit of a beach in SF and NY right now, and I'm really eager to help out myself as well. |
be06518
to
05b5f6e
Compare
Travis is now passing and I have resolved the shared examples context issue as well. I'm looking forward to more feedback on this, but I believe it's about ready to merge! |
This is a modernization bringing them in line with what our spec template has had for a while. We also no longer need to conditional importing with quotes or angle brackets depending on platform
* Remove requirement that Cedar.h itself only be imported by Objective-C++ files * Conditionally compile C++ constructs in individual headers
* Cedar.h now only imports the various sub-umbrella headers for different subsystems * Add CedarReporters.h so the reporter headers (already public!) get imported * CDRSpec.h no longer imports headers related to matchers and doubles * Properly copy the ContainSubset matcher header
This better advertises API intention, as well as improving the experience of Swift users. Unfortunately this does require silencing Clang warnings in a few `-dealloc` methods which set `nonnull` properties to nil during cleanup.
This ensures that the context gets bridged into Swift as a reference type instead of a value type.
f8bf63a
to
d5c9b4b
Compare
I have updated this to include Xcode snippets for the standard Cedar BDD constructs in Swift, as well as added the option to the file template to generate a Swift spec. Thanks to @modocache for the Quick spec template which I used as a reference for how to add a language picker! With this, I feel that this is ready to be merged into master to receive broader feedback. |
(I'll defer to someone else for adding Swift snippets for AppCode when the need is felt for them!) |
I don't have nearly enough emoji to express my excitement right now. This will have to suffice. |
Swift support for the Cedar test runner
As more and more projects are expressing interest in using Cedar in pure-Swift and (especially) mixed Objective-C and Swift contexts, I've taken some steps towards a maintainable approach to making the Cedar test runner, including the
describe
,it
, etc. DSL available from Swift. To be clear, Cedar matchers and doubles remain inaccessible from Swift due to their reliance on C++. (See discussion at #259)I consider this to be an evolution of great proof-of-concept work done by @tjarratt and @Jdavid1001 on the
swift-spec-runner
branch a while back. The key difference is that this branch makes the existing Cedar framework targets importable from Swift, instead of introducing additional targets dedicated to the runner.Have a look at the individual commit messages to see the whole story, but the highlights here are:
XCTAssert*
functions from specs defined in Swift, as well as out-of-the-box support for other matcher frameworks (in particular Nimble) that report failures through XCTest.With this PR, it is possible to add a Swift file like the following to an existing Cedar test suite or bundle: