Tuesday, July 22, 2014

XCTest​Case / XCTest​Expectation / measure​Block()

Mattt Thompson:

With Xcode 6, we’ve finally arrived: the built-in testing tools are now good enough to use on their own. That is to say, there are no particularly compelling reasons to use any additional abstractions in order to provide acceptable test coverage for the vast majority apps and libraries. Except in extreme cases that require extensive stubbing, mocking, or other exotic test constructs, XCTest assertions, expectations, and performance measurements should be sufficient.

I do find it helpful to use additional macros to make the assertions more concise. For example, I use EQ() instead of XCTAssertEqualObjects(). This was also nice because I didn’t have to change all my code when Apple renamed its macros. I also have macros like EQARRAY() that make it easier to see how the failing object differs from the expected one. And I have ones for structs like NSPoint because Apple removed support for those with XCTAssertEqual() and never added it back.

Comments RSS · Twitter

Leave a Comment