Book Image

Test-Driven iOS Development with Swift

By : Dr. Dominik Hauser
Book Image

Test-Driven iOS Development with Swift

By: Dr. Dominik Hauser

Overview of this book

Test-driven development (TDD) is a proven way to find software bugs early. Writing tests before your code improves the structure and maintainability of your app. Test-Driven iOS Development with Swift will help you understand the process of TDD and how it impacts your applications written in Swift. Through practical, real-world examples, you’ll start seeing how to implement TDD in context. We will begin with an overview of your TDD workflow and then deep-dive into unit testing concepts and code cycles. We will showcase the workings of functional tests, which will help you improve the user interface. Finally, you will learn about automating deployments and continuous integration to run an environment.
Table of Contents (15 chapters)
Test-Driven iOS Development with Swift
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Getting started with Xcode


Now, let's start our journey by creating a project that we will implement using TDD.

Open Xcode and create a new iOS project using the Single View Application template. In the options window, add ToDo as the product name, select Swift as language, choose iPhone in the Devices option, and check the box next to Include Unit Tests. Let the Use Core Data and Include UI Tests boxes stay unchecked.

Xcode creates a small iOS project with two targets: one for the implementation code and the other for the unit tests. The template contains code that presents a single view on screen. We could have chosen to start with the master-detail application template because the app will show a master and a detail view. However, we have chosen the Single View Application template because it comes with hardly any code, and in TDD, we want to have all the implementation code demanded by failing tests.

To take a look at how the application target and test target fit together, select the...