Beginning iOS Unit and UI Testing - Part 2: Test | Ray Wenderlich

In this video tutorial on unit and UI testing in iOS, you’ll learn the basics of unit testing by setting up a test target, accessing your app's code and writing your first set of tests.

This is a companion discussion topic for the original entry at

Hi Joshua, thanks for this tutorial!

QQ for you: how do we get the challenge solution to fail in a way that is recognized as a failure by XCTAssert?

The easiest thing would be to simply comment out the implementation code. For example,

public func addPancakeHouse(_ pancakeHouse: PancakeHouse) {
//    _pancakeHouses.append(pancakeHouse)

Likewise for the removePancakeHouse(_:) method.

In test driven development (covered later in this series), you would have wrote this test before the production code. So, this basically simulates this.


1 Like

Hi Josh,
In the tutorial you use test data stored in a plist. Can you explain why you do this instead of using the existing pancake_houses.plist? Although in this app the model data is stored in the 'pancake_houses.plist`, I imagine this was originally done to simplify the app, whose purpose is to demonstrate how stack views are implemented. In a production app this information would probably be sent over a network. Do you use the test plist to show how to avoid network calls for test data? Should we always do this in our own apps? My understanding is it is best practice to avoid network calls in test data, as this can slow your tests down and we are testing the code, not the network calls.