Technically you’re an iOS developer, but you’re starting to feel more like a QA tester.

You cringe when you see the notification. Another bug report assigned to you.

You click back and forth between source files for hours trying to figure out what to do, knowing that if you don’t get this exactly right, something else will break and you won’t even know until you start seeing one-star reviews.

Eventually you decide to just try something, so you make a change to the code and run the app. It takes six taps just to get to the screen you need, then you have to type data into all eight text fields to test it. And that’s just the happy path; you’ll have to do it all again to test the error cases.

Given how unstable the codebase is, you wouldn’t be surprised to see another feature break, so once you’ve fixed the bug you’ll have to run a bunch of manual regression tests to make sure everything else still works. Sigh. Maybe tomorrow you’ll get to write some code.

Refactoring your massive view controllers seems like it would help, but the code is so brittle, you’re guaranteed to break something. And then you’d be back where you started — running tests instead of building features — when you’re already behind schedule.

What if you didn’t have to spend all your time testing brittle code?

Let’s consider another scenario…

Imagine being free to focus on doing what you do best: developing features your users will love.

You grin when you see the notification. Another five-star review!

After reading the entire review twice, you feel a new surge of motivation as you Command-Tab back to Xcode to finish building that new feature. Each time you develop a new component, you sit back and relax as your code automatically tests itself. When the tests pass, you’re confident that the feature you just built is stable and that the existing features still work the way they should.

You get the feature done a day ahead of schedule, and you’re confident that it’s solid — your automated tests are proof that it works exactly as it should.

You’ve been consistently able to ship new features much faster than before. Your safety net of automated tests has boosted your confidence, giving you the ability to quickly make changes to your code.

Whenever you notice a bit of code that needs to be cleaned up, you take a few minutes to refactor it, confident that it still works the way it should when you’re done. As a result of your frequent refactoring, your codebase is a joy to work with.

Free yourself of the burden of manual testing so you can ship solid features faster.

With a suite of unit tests that verifies your code quickly, frequently, and automatically, you can relieve yourself of the responsibility of manually testing everything. You’ll have more time to focus on building features, and you’ll be able to ship them faster when you’re confident that the changes you make don’t create bugs in the rest of the app. Every time your tests run, you’ll have proof that your code is stable and works the way it should.

And guess what? You don’t even need to spend the next six weeks rewriting your code and adding unit tests. Unit Testing in Swift will help you write your first tests in a few minutes and show you how to build up your test suite over time. You’ll be able to sit back and relax while your code tests itself, and you’ll be confident that it works correctly.

With Unit Testing in Swift, you’ll:

    • automate your testing process one requirement at a time so you don’t have to waste precious development time verifying everything manually
    • catch bugs before anyone else sees them by establishing good automated testing practices
    • speed up your debugging process by writing unit tests that’ll make it easier to find and fix bugs
    • build a regression test suite so you can avoid breaking features your users need
    • create a safety net for yourself so you can refactor spaghetti code with confidence

And you’ll have the peace of mind that comes from shipping an app you know is solid.

What’s in the book?

The book will guide you through setting up your Xcode project and writing unit tests for your view controllers, networking classes, JSON parser, and business logic. You’ll be able to add tests to your project as you go, and you’ll build confidence in your code each time you add another test that proves it works correctly.

  1. What are the benefits of unit testing?
  2. How to write your first unit tests in Swift
  3. Why test first, rather than test after?
  4. Practicing TDD: Red, Green, Refactor
  5. Validating text entry in a view controller
  6. What types of requirements are best left for manual testing?
  7. Verifying your code frequently and automatically with continuous integration
  8. Testing the collection view
  9. Testing REST API requests
  10. Mocking the URLSession API
  11. Testing asynchronous code using XCTestExpectation
  12. Testing the JSON parser
  13. Mocking the JSON Parser
  14. Stubbing the API client
  15. Mocking the image API request
  16. Building your unit test suite gradually over time
  17. Increasing your confidence with test coverage
  18. Mastering the art of unit testing
  19. Maintaining your safety net with good development practices

The Expanded Edition (beta)

  • PDF of Unit Testing in Swift
  • The tests and source code for the Top Movies app so you can see how to apply the concepts in the book to your own project
  • Video: How to refactor your Swift code using TDD

With the source code for the Top Movies app, you’ll be able to copy and paste unit tests into your own project to start building your automated test suite right away. The video will guide you through adding tests to an existing app as you refactor — and you’ll end up with cleaner code, confident that it works correctly.

Start Unit Testing in Swift today. Get the beta Expanded Edition for $69 $59

You’ll save 15% when you buy the beta, and you’ll get a free upgrade to the final version when it’s ready.

Want to share with your team?

Get a team license and share the book, source code, and video — everything in the Expanded Edition — with up to 10 people so your entire team can be more productive.

Purchase a team license for $349 $297

You’ll save 15% when you buy the beta, and you’ll get a free upgrade to the final version when it’s ready.


The Basic Edition (beta)

  • PDF of Unit Testing in Swift

If you’re confident you can implement the concepts in the book on your own, this edition is for you.

Start Unit Testing in Swift today. Get the beta for $39 $33

You’ll save 15% when you buy the beta, and you’ll get a free upgrade to the final version when it’s ready.


What’s the deal with the beta?

Unit Testing in Swift is currently in beta. All the chapters are written and can help you start unit testing your app today. There are some typos, grammatical errors, and flow issues, so if you want a completely polished book, the beta isn’t for you. If you can overlook those minor problems, you’ll be able to learn everything today that you’d learn from the final version when it’s released.

When you get the beta version, you save 15% and get a free upgrade to the final version.

Can I try a free sample?

Absolutely you can! Grab your free sample below and start Unit Testing in Swift today.

What format does the book come in?

You can download Unit Testing in Swift as a PDF.

If I buy the Basic Edition now, can I upgrade later for the difference?

Yes! Send me an email and I’ll help you upgrade to the edition you want.

What if I’m not happy with the book?

I want you to be happy with it, so if for some reason you’re not, just send me an email and I’ll give you a refund as soon as I can.

Who’s the author?

Hi, I’m Josh Brown. I’ve been writing unit tests for the last ten years. A couple years ago, I wrote Parsing JSON in Swift to teach people how to — you guessed it — parse JSON in Swift. I’ve been developing iOS apps for our clients — from trucking apps to food logging apps to contact management apps and more — since 2009. Most recently, I’ve been helping my coworkers start unit testing and writing everything I can about it. I hope this book makes it easier for you to get started.

I have another question.

Send it my way and I’d be happy to answer it.