📈 Unit Testing in Swift: Introduction

Test, test, test!

As much as it may sound like a WHO recommendation in the middle of a COVID19 pandemic, it’s not. It’s the general recommendation for any software developer who values great code quality and peace of mind while developing.
In the following series I will cover everything from why you should thoroughly test your Swift code to how to implement advanced mocking of internal classes in Swift.

The series contains the following articles:

With the table of contents done and dusted, let’s get on with it!

“…But why test a mobile app project?”

Every now and then I bump into developers asking me why there is a need for unit testing mobile application projects; after-all most of the code is UI-related anyway. This question is part of my motivation for writing this article, as I strongly believe that every software developer should be writing unit tests — even in solo projects. The answer to the question is simple:

“To prevent you from introducing bugs!”

As harsh as it may sound, it is the truth: Unit tests ultimately keep track of the logic within your application, so that you don’t have to remember it yourself.
In the beginning it may seem easy to remember how and why your code behaves how it does, but in time your logic will inevitably be extended, new developers may enter the arena or you may simply just forget how certain modules are supposed work. This is where unit tests save your day. With a proper test suite you will be aware of any regressions added with newly introduced code, before it’s pushed. In addition, both you and the new developer on your team will feel significantly more comfortable, knowing that no unit tests fail in the first commits.

The list of specific advantages of unit testing is long. While this should be reason enough for you to start testing, I understand that you may not be convinced just yet. So don’t take my word for it — instead listen to the community!

As always, if you have any questions or comments, feel free to reach out to me by commenting on these articles. I will reply to all messages.

Happy reading!

--

--

--

Lead iOS Engineer @ Jabra 🇩🇰 Full time 💻📲 — part time 🚴🏽‍⛷🏃🏽‍🏊🏼‍

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Autolayout with Anchors in swift

How to Build a Live Video Streaming iOS App with Agora

banner image, showing a live streaming app

Combine: From zero to… Oh! I get it. (Part I)

Part 2: Setting the App in Frameworks

How to Create an iOS or macOS Video Streaming Application with a Few Lines of Code

Quickstart with Agora UIKit for iOS

[iOS]Making a Contact-like app using CoreData

What I’m Reading Today

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Kewin

Kewin

Lead iOS Engineer @ Jabra 🇩🇰 Full time 💻📲 — part time 🚴🏽‍⛷🏃🏽‍🏊🏼‍

More from Medium

Test Driven Development: Simple Flow Object in iOS

True or False?

Struct vs Classes

From ObjC → Swift → ObjC: Part 1