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
[SR-1110] Add convenience XCTestExpectation constructors for NSPredicate #396
Comments
This task is blocked until swift-corelibs-foundation implements NSPredicate. See: apple/swift-corelibs-foundation#127 |
apple/swift-corelibs-foundation#127 was merged! apps.yoon (JIRA User), do you still want to take this on? |
Comment by Kyle Yoon (JIRA) @modocache Sure thing! Assigning to myself. |
Comment by Kyle Yoon (JIRA) @modocache Could I get you thoughts on my implementation: Since `expectation(forPredicate...)` needs to re-evaluate the predicate periodically, and `waitForExpectations(...)` runs a loop to check if the expectation `isFulfilled`, I make a subclass of `XCTestExpectation` that:
Would you be against adding this subclass? |
I think a subclass sounds fine--in fact, I think Apple's XCTest uses a subclass. I don't think it overrides But that aside, I'd be fine with pretty much any working implementation, even one that overrides By the way, have you seen this FIXME? Perhaps using a runloop source that could be signaled would make it easier to implement this? If not no worries, just a heads up. |
Comment by Kyle Yoon (JIRA) @modocache |
Comment by Kyle Yoon (JIRA) I've tried using the regex Full line:
|
apps.yoon (JIRA User): |
Comment by Kyle Yoon (JIRA) @modocache Ignore that 😃 sorry! |
Comment by Kyle Yoon (JIRA) And yes, your regex fix worked. Thank you! |
Attachment: Download
Additional Detail from JIRA
md5: 80de972c44d4ad944e39eb5cd68136b2
Issue Description:
Apple XCTest offers several convenient methods for constructing XCTestExpectations:
Key-value observing doesn't exist in native Swift, but NSNotification and NSPredicate do (thanks to swift-corelibs-foundation). swift-corelibs-xctest already defines a constructor for NSNotification: https://github.com/yoonapps/swift-corelibs-xctest/blob/c2a9258c7c17e32bf9082709ef111e59aba86a95/Sources/XCTest/XCTestCase.swift#L324. This was added in #85
Add the constructor for NSPredicate:
-[XCTestCase expectationForPredicate:evaluatedWithObject:handler:]
.Also, note that you'll need to add the following closure typealias as well:
typedef BOOL (^XCPredicateExpectationHandler)();
.https://bugs.swift.org/browse/SR-907 is a great reference on how to approach this task.
The text was updated successfully, but these errors were encountered: