Summary

In this chapter, we wrote tests using test expectations provided by XCTest. We also used stubs to fake a server. We took a look at how both ways bring us closer to our goal: a finished app with as few bugs as possible.

We used dependency injection to catch the completion handler of the session data task in our fake URL session. This way, we could feed test data into the implementation code and assert that the code is implemented as expected. As we controlled the data that the completion handler received, we were able to simulate all kinds of errors and drive the implementation of the correct error handling.

Using the keychain access as an example, we took a look at how to write tests for features that are yet to be implemented.

In the following chapter, we will put the different parts of the last few chapters together and finally see the app running.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.216.190.182