Why iOS developers don’t write unit tests

Photo by Stanley Dai on Unsplash

Last week I asked my mailing list “What keeps you from writing unit tests?” and got more than 30 responses. (If you didn’t participate and want to, just send me an email with your answer to josh@roadfiresoftware.com.) Today I’m sharing the anonymized results, hoping they’ll help all of us become more aware of why we don’t write unit tests — whenever we don’t. Even though I usually write tests, there are certainly times that I don’t, and knowing why helps me to know whether I’m being pragmatic or just making lame excuses.

Here’s what keeps iOS developers from writing unit tests, ordered from most common to least.

I don’t see the benefit.

The majority of responses fell into this category; lots of developers don’t see the benefit of writing unit tests or even believe they’re harmful.

“I haven’t seen much — if any — benefit to justify the investment.”

“never really bothered about [unit testing] since we had in-house testers”

“They don’t catch every error. An incomplete unit test suite can lull you into thinking you have captured all error conditions.”

These are all good reasons not to write unit tests. If you don’t understand the value or think they’re a waste of time, you probably shouldn’t be writing them. I get a lot of benefit from unit testing and plan to share them with you next time; if you’re in this group, I hope you’ll see how useful unit tests can be even if you do have a testing team.

I don’t know how.

Another big reason iOS developers don’t write unit tests: they don’t know how.

“I don’t know enough on how to use/incorporate unit tests”

“I just find it overwhelming to try and start”

I’m not surprised this is the second-biggest reason iOS devs don’t test; as one person said, “there are no tests in tutorials, never.” Later in this series you’ll learn how to write your first tests so you don’t have to miss out on the benefits just because you’re unsure of where to start.

I don’t have enough time

The third-most popular reason to not write unit tests: not enough time.

“projects do not allow enough development time to get good coverage on tests”

“my customer does not pay me for extra hours spent on tests :(”

I’ve certainly fallen into this category before; on one of my projects, our manager told us he knew we’d need to compromise quality in order to meet our deadline. We stopped writing unit tests and doing thorough code reviews so we could ship the app on time — with a bunch of bugs — but then we were able to focus on quality and get back into those habits.

It’s hard.

There’s no doubt that unit testing can be hard, especially when you’re first starting out. But even if you’re experienced, it can be time-consuming to set up testing scenarios.

“unit testing is certainly important for writing good code, but it’s also difficult”

Additionally, some developers believe code needs to be written differently in order to be tested, making it more difficult to write tests.

“You have to do a lot of things like ViewModels and the like to do [unit tests]”

And one developer even responded that “laziness” is what kept them from writing unit tests. I love an honest answer. 😄

All of these are good reasons: unit testing can be hard in a lot of cases, and sometimes it’s not worth the investment. Sometimes I don’t test things because the setup is too much, but I generally find unit tests to be worth the effort they take to develop.


I also noticed that a lot of people said they should write tests but either don’t know how or don’t feel like they have enough time.

Whatever keeps you from writing unit tests, you’re not alone. I hope having more awareness about unit testing helps you to think more about whether you should keep doing what you’re doing — or make changes if there are areas you could improve. I usually write unit tests and find lots of value in them; in the next article, I’ll explain all the benefits I’ve seen.

Enter your name and email in the boxes below to get it!