Matchers that ship with Xcode's testing framework could be improved
| Originator: | weyert | ||
| Number: | rdar://34882040 | Date Originated: | 09-Oct-2017 11:31 am |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | |
| Classification: | Security | Reproducible: | Always |
Summary:
This is a duplicate of radar #34875723
Okay so: matchers. Matchers are how developers write assertions in unit tests. Currently the matchers that ship with Xcode are fairly limited. They're a simple function that performs an assert under the hood (I think).
XCTAssertEqual(objectA, objectB)
That's fine but it's not really expressive, and it doesn't take advantage of some really cool techniques used in other languages to unit test. For example, take Nimble. Nimble is a matcher library that can be used with XCTest that provides expressive and extensible matchers. It's open source, available here: https://github.com/Quick/Nimble
expect(objectA) == objectB
Honestly I'd like it if Xcode just _shipped_ with Nimble included, but I get that Apple can't necessarily do that. So instead, I'd suggest copying all the features and capabilities of Nimble. I'm a Nimble maintainer, and it would be awesome if Nimble were completely sherlocked in the next release of Xcode. Here are some other examples from Nimble's readme:
expect(1.2).to(beCloseTo(1.1, within: 0.1))
expect(3) > 2
expect("seahorse").to(contain("sea"))
expect(["Atlantic", "Pacific"]).toNot(contain("Mississippi"))
Looming forward to hearing back.
Steps to Reproduce:
Expected Results:
Actual Results:
Version:
Notes:
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!