Reader small image

You're reading from  Test-Driven iOS Development with Swift - Fourth Edition

Product typeBook
Published inApr 2022
PublisherPackt
ISBN-139781803232485
Edition4th Edition
Right arrow
Author (1)
Dr. Dominik Hauser
Dr. Dominik Hauser
author image
Dr. Dominik Hauser

Dr. Dominik Hauser is an iOS developer working for a small company in western Germany. In over 11 years as an iOS developer, he has worked on many different apps, both large and small. In his spare time, Dominik builds small (often silly) apps and explores how he can become a better iOS developer. He talks at conferences, writes books, and is active in the iOS community in general. His most successful open source component (in terms of stars) is a pull-to-refresh control for a table view that consists of an actual SpriteKit game. Before Dominik became an iOS developer, he was a physicist, researching the most powerful photon sources within our galaxy.
Read more about Dr. Dominik Hauser

Right arrow

Understanding the difference from other kinds of tests

Unit tests are just one piece of a good test suite. In my opinion, they are the most important tests because when carried out correctly, they are fast, focused, and easy to understand. But to increase your confidence in your code, you should additionally add integration, UI/snapshot, and manual tests. What are those?

Integration tests

In integration tests, the feature that is being tested is not isolated from the rest of the code. With these kinds of tests, the developer tries to figure out if the different units (that are thoroughly tested with unit tests) interact with each other as required. As a result, integration tests execute real database queries and fetch data from live servers, which makes them significantly slower than unit tests. They are not run as often as unit tests and failures are more difficult to understand as the error has to be tracked down in all involved code units.

UI tests

As the name suggests, UI tests run on the UI of an app. A computer program (the test runner) executes the app as a user would do. Usually, this means that in such a test assertion, we also have to use information accessible on screen. This means a UI test can only test whether a feature works as required when the result is visible on screen. In addition, these tests are usually quite slow as the test runner often has to wait until animations and screen updates are finished.

Snapshot tests

Snapshot tests compare the UI with previously taken snapshots. If a defined percentage of pixels differs from the snapshot image, the test fails. This makes them a perfect fit for situations where the UI of one app screen is already finished and you want to make sure that it won't change for given test data.

Manual tests

The final kind of test in the development of an app is a manual test. Even if you have hundreds of unit and integration tests, real people using your app will most probably find a bug. To minimize the number of bugs your users can find, you need testers in your team or to ask some users for feedback on the beta version of your app. The more diverse the group of beta testers is, the more bugs they will find before your app ships.

In this book, we will only cover unit tests because test-driven development (TDD) only works reasonably well with fast reliable feedback.

Previous PageNext Page
You have been reading a chapter from
Test-Driven iOS Development with Swift - Fourth Edition
Published in: Apr 2022Publisher: PacktISBN-13: 9781803232485
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime

Author (1)

author image
Dr. Dominik Hauser

Dr. Dominik Hauser is an iOS developer working for a small company in western Germany. In over 11 years as an iOS developer, he has worked on many different apps, both large and small. In his spare time, Dominik builds small (often silly) apps and explores how he can become a better iOS developer. He talks at conferences, writes books, and is active in the iOS community in general. His most successful open source component (in terms of stars) is a pull-to-refresh control for a table view that consists of an actual SpriteKit game. Before Dominik became an iOS developer, he was a physicist, researching the most powerful photon sources within our galaxy.
Read more about Dr. Dominik Hauser