mokacoding

unit and acceptance testing, automation, productivity

Test-Driven Development in Swift is now available

Test-Driven Development in Swift is now available on Apress, Amazon, and anywhere else you get your books.

A picture of the paperback version of the book

Test-Driven Development in Swift is the culmination of a decade of practicing, researching, writing, and speaking about TDD. It's the book I wish I had when starting out: a practical, step-by-step course on how to write iOS applications using Test-Driven Development.

But don't take it from me! Here's what early readers are saying about the book:

Structured in just the right way to help you grasp the complicated topic of Test-Driven Development. With detailed descriptions of concepts and ideas alongside coding examples, it gives you everything you need to grow your testing skills.

If you’re unfamiliar with Test-Driven Development, this book is a great introduction, building up one clear example at a time. If you are familiar with TDD, the book will teach you the testing toolkit you should be using in Swift.

As I was working through the book, one of the things it taught me very early on, which I realized that I had been kinda doing, but I was just failing because I wasn't thinking about it the right way, was how to break things down into small chunks of solvable problems.

What makes this book unique is that it approaches TDD in SwiftUI and Combine.

You'll learn why the best way to test a SwiftUI app is not to test SwiftUI code and what to do instead. (Hint: put all the logic into a pure Swift object and use TDD on it).

You'll see how to leverage the synergy between SwiftUI and Combine to offload all the heavy lifting of keeping views in sync with dynamic data, and how to test the thin code layer that transforms backend data into presentation data.

You'll discover the different kinds of Test Doubles, test-specific equivalent of production code dependencies, and when and how to use them.

If you're like me, you like to sample before committing. On the publisher's site, you can get a preview of the first pages of each chapter, and all the code from the book is available on GitHub.

Each chapter answers a practical question, such as "How do you use Test-Driven Development for the view layer when there is no straightforward way to test SwiftUI views?", "How do you write tests for code interfacing with the network?" and "How do you apply TDD to change the behavior of existing code?" in the concrete landscape of a real-world application.

And even though the book focuses on writing tests for a SwiftUI application with vanilla XCTest, it comes with appendixes on how to apply the same concepts to tests written Quick and Nimble or UIKit applications.

I'm super excited to finally be able to share Test-Driven Development in Swift with you. I hope you'll check it out and can't wait to hear what you think! Get in touch by leaving a comment below or via Twitter at @mokagio.

Want more of these posts?

Subscribe to receive new posts in your inbox.