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, 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. 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 project in the Project Navigator, and then select the ToDoTests target. In the General tab, you'll find a setting for the Host Application that the test target should be able to test. It looks like this:

Xcode has already set up the test target correctly to allow the testing of the implementations that we will write to the application target.

Xcode has also set up a scheme to build the app and run the tests. Click on the scheme selector next to the Stop button in the toolbar, and select Edit Scheme.... In the test action, all the test bundles of the project will be listed. In our case, only one test bundle is shown--ToDoTests. On the right-hand side of the shown window is a column named Test, with a checked checkbox. This means that if we run the tests while this scheme is selected in Xcode, all the tests in the selected test suite will be run.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.131.13.165