Summary

Congratulations! You've made it to the end of this lengthy, information packed chapter. You've learned a whole lot about maintaining a high standard of quality for your apps and how to do this by writing tests for your code. You learned about different types of tests and how to structure them to maximize their quality and reliability.

We've refactored existing code to make sure that we can properly test it and we've gained a lot in the process. Writing tests for your code enforces you to think about the ways in which your code relies on external factors and other pieces of code. This isn't always a good or bad thing, but once you start writing tests, you'll find that the more explicit and configurable these dependencies become, the easier it is to test your code.

You've also seen how protocols can abstract away the actual type and implementation of, for instance, an API. Abstracting our API into a protocol and making the dependency explicit in our question loader made it so that we could easily swap out the networked version of the API for an offline, file-based API. This approach works well for APIs but it works just as well for many other dependencies or objects that you might find in code that you write yourself.

After testing your app logic, you learned about testing your app's UI. You saw how to record UI tests and how to manually write them. You also learned a couple of things about accessibility in the process because UI tests rely on your app's accessibility. We explored accessibility a little bit and saw that it's not very hard to make your app accessible and more testable because UIKit and iOS have very high accessibility standards out of the box.

With all the knowledge from this chapter, you should be able to begin writing great, reliable tests for your own apps. Writing tests can be tedious sometimes and it might seem like it's overkill or just a chore. Especially if you're working on a smaller project it can be tempting to skip testing altogether. I would recommend you always write tests for your code, no matter how small or simple the project. Tests can force you to write modular, well-structured code. Especially if you practice Test Driven Development. If you're interested in learning more about the topic of testing, you could have look at Test-Driven iOS Development with Swift 3, written by Dr Dominik Hauser. This book takes a practical approach to developing an iOS application using TDD principles.

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

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