Manual code and UI testing get slower the deeper your navigation hierarchy goes. It can take several taps just to reach a particular screen, never mind the actual workflow tests. Automatic unit testing offers such rapid feedback that it can change the rules of development. Bring testing to iOS development, even for legacy code. Use XCTest to write unit tests in Swift for all your code.
iOS developers typically reserve unit tests for their model classes alone. But that approach skips most of the code common to iOS apps, especially with UIViewControllers. Learn how to unit test these view controllers to expand your unit testing possibilities. Since good unit tests form the bedrock for safe refactoring, you’re empowered to make bold changes. Learn how to avoid the most common mistakes Swift programmers make with the XCTest framework. Use code coverage to find holes in your test suites. Learn how to identify hard dependencies.
Reshape the design of your code quickly, with less risk and less fear.
It is just amazing. Very clear explanations and the most importante thing, as the title of the book says, doing it by examples is the best way to learn.
The book provides a solid introduction to the core principles of unit testing in iOS and established best practices in software engineering. It serves as an excellent primer on Test-Driven Development (TDD) and is well-crafted, offering crucial knowledge for enhancing the quality of iOS development and the refactoring process.
However, the content could be more up-to-date. It should discuss contemporary iOS development methodologies, including structured concurrency, SwiftUI, and Combine/Observation frameworks. The book adheres to an "older" iOS app development approach and omits the discussion of current trends like handling asynchronous events and managing data flows with publishers and subscribers. This gap is particularly evident in the chapter on the MVP (Model-View-Presenter) design pattern. MVP, being inherently imperative, does not integrate as smoothly with the reactive paradigm of SwiftUI, making it unsuitable for today's standards.
Despite these limitations, the book remains an invaluable resource and a rewarding read/exercise. I highly recommend it.
Do check my GitHub repository for this book, where all tests + TDD package are conveniently hosted in a single Xcode (version 15) project: https://github.com/backslash-f/assert...
This is truly a great book on iOS testing. It has plenty of ideas that will definitely make you a better developer — 100% guaranteed. My only downside is that it feels a bit outdated because it focuses on frameworks that are currently being replaced. It puts a lot of emphasis on UIKit, whereas SwiftUI is now the star of the show, with a quite different approach to testing. XCTest is being replaced by Swift Testing, and there’s no mention of how to test reactive event streams. I believe there’s room for a new testing book focused on SwiftUI, Combine, modern concurrency, and Swift Testing.