Snippets to test the behavior of Combine Publishers in XCTest ready to copy and paste into Xcode
The XCTest Swift testing framework has a limited offer of assertions. There's only so much you can do with XCTAssertTrue and XCTAssertEqual. This XCTest tutorial shows how to create custom assertions to make your unit tests and UI tests shorter and clearer.
Result is one of the most useful types in the Swift language. Learn how to write better unit tests using Result in this XCTest tutorial.
When the output value of a function changes often but the logic to pick it doesn't, adding a separation layer will make unit tests easier to maintain.
Some code ends up requiring a lot of duplication to be tested. You can remove it by using helper functions encapsulating the shared assertion logic.
Testing async code is not simple, but XCTest provides us with all the required tool. This post shows how to wait for an expectation to be fulfilled based on a Swift closure.
In this second post of the Practical Testing in Swift we a look at strategies to test how objects call their delegate methods or set property on them.
Writing unit tests for our iOS and OS X projects not only is important, but should be always part of the development cycle. As such the way we write the tests is as important, and having the option to write tests that easily explain their purpose can drastically increase the quality of the suite. Specta and Expecta are two libraries that provide a different way to writing tests than XCTest, let's see what we can gain by using such approach.