Jump to ratings and reviews
Rate this book

iOS Unit Testing by Example

Rate this book
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.

300 pages, Paperback

Published November 10, 2019

19 people are currently reading
188 people want to read

About the author

Jon Reid

1 book8 followers

Ratings & Reviews

What do you think?
Rate this book

Friends & Following

Create a free account to discover what your friends think of this book!

Community Reviews

5 stars
21 (48%)
4 stars
21 (48%)
3 stars
1 (2%)
2 stars
0 (0%)
1 star
0 (0%)
Displaying 1 - 8 of 8 reviews
5 reviews
December 14, 2020
Good introduction to testing with a bunch of sections dedicated to iOS-specific APIs.

I liked the latter sections where they gradually refactored the same app to different architectures.
Profile Image for Mauricio Chirino.
122 reviews9 followers
August 27, 2021
Must read for any iOS dev

Whether you’re starting out in testing or already have a little bit of experience in the matter under your belt, this is a must read book.

One of the nicest thing it has is that it allows scanning it through until you find that little nugget of information you we’re looking for
Profile Image for Matías.
6 reviews2 followers
May 17, 2022
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.

10/10
Profile Image for Steven.
1 review
December 29, 2022
Great book for any Swift developer. Covers testing iOS in great detail but also some great chapters on refactoring and TDD.
Profile Image for Fernando Fernandes.
129 reviews8 followers
November 19, 2023
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...
Profile Image for Ivan Ornes.
7 reviews4 followers
August 22, 2025
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.
Displaying 1 - 8 of 8 reviews

Can't find what you're looking for?

Get help and learn more about the design.