Unit Testing in Swift

Eniela P. Vela
Swift Blondie

--

Picture by Sigmund in Unsplash.

Unit testing is a process of executing a program and checking that it behaves as expected. If you’re reading this tutorial, you already know you should write unit tests for your code and UI, but you may not know how to get started using Xcode. This tutorial will show you how to:

- Use Xcode’s Test navigator to test an app’s model and async functionality

- Set up unit tests for views and unit tests for controllers

- Write unit tests for asynchronous code

- Learn how to write unit testing suites, where you can group related unit tests together.

Unit testing is an essential part of iOS development, and Xcode makes it easy to get started. So let’s get testing!

What unit tests can (and cannot) do for you:

Unit tests will not make your code immune from bugs and crashes, but they will save you a lot of time in the long run by letting you catch problems earlier in the development process. Writing unit tests forces you to focus on the behavior of your code, which means you’re less likely to miss unit tests for critical parts of your app.

Now that you know why unit testing is important, let’s take a look at how Xcode can help get you started with unit testing iOS apps.

How do I get started?

--

--

Eniela P. Vela
Swift Blondie

iOS Developer | Technical Writer | Software Developer @ Apple