Skip to content

[4.2] [SR-7615] Implement XCTWaiter and missing XCTestExpectation APIs #228 #245

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

Closed
wants to merge 3 commits into from

Conversation

glbrntt
Copy link

@glbrntt glbrntt commented Feb 7, 2019

See master PR: #228

- Change the object parameter of `XCTestCase.expectation(for:evaluatedWith:handler:)` from
  type `AnyObject` to `Any?` with a default value of `nil`. This more closely matches the
  type of the object parameter from the NSPredicate initializer.
- Modify the internally-formatted `description` string to match ObjC XCTest implementation.
- Update and add new unit tests

(cherry picked from commit 6cb41b9)
This brings Corelibs XCTest up-to-date with ObjC XCTest's modern asynchronous waiting APIs.

This has been requested both via Radar (rdar://problem/41022833) and Swift JIRA ([SR-7615](https://bugs.swift.org/browse/SR-7615), [SR-6249](https://bugs.swift.org/browse/SR-6249)). It is effectively a rewrite of this project's asynchronous testing logic to match the behavior of Apple's ObjC framework.

- Implement missing `XCTestExpectation` APIs including:
  - `expectedFulfillmentCount`
  - `isInverted`
  - `assertForOverFulfill`
- Implement `XCTWaiter` class and `XCTWaiterDelegate` protocol
- Publicly expose the `XCTNS(Predicate,Notification)Expectation` classes
- Re-implement `XCTestCase.waitForExpectations(timeout:handler:)` to use XCTWaiter and add `XCTestCase.wait(for:timeout:)`
- Implement "nested waiter" behavior, using a new internal helper class `WaiterManager`
- Add documentation comments to all public APIs, based on their ObjC counterparts
- Add a utility struct called `SourceLocation` which represents a file & line
- Update expectation handler block typealiases to match current ObjC names
- Match various API call syntaxes to their ObjC counterparts
- Introduce a `subsystemQueue` DispatchQueue for synchronization, shared between XCTWaiter and all expectations
- Modify XCTestCase's "un-waited" expectations failure message to note all un-waited on expectations, to match ObjC
- Add many new tests

(cherry picked from commit ffa81a2)
@stmontgomery stmontgomery self-assigned this Feb 7, 2019
@stmontgomery
Copy link
Contributor

@swift-ci Please test

@kevints
Copy link

kevints commented Feb 18, 2019

@swift-ci test 4.2

@kevints
Copy link

kevints commented Feb 18, 2019

@swift-ci please test

@glbrntt
Copy link
Author

glbrntt commented Feb 18, 2019

@swift-ci Please test

@glbrntt
Copy link
Author

glbrntt commented Feb 19, 2019

@swift-ci please test

@glbrntt
Copy link
Author

glbrntt commented Feb 19, 2019

Closing as this is an API change which breaks SemVer.

@glbrntt glbrntt closed this Feb 19, 2019
@glbrntt glbrntt deleted the pr_sr_7615_42 branch February 19, 2019 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants