Unit and integration testing with XCTest
Testing plays a massive role in the software development life cycle. Primarily, there should be a lot of focus on physical user testing – putting your piece of code in the hands of those who use it day in and day out. This should be one of our main focuses, but what about testing what we, as software developers, do? How do we test and check the integrity of our code base?
This is where unit testing and integration testing come in. In this recipe, we’ll cook up a unit and integration test for our previously written Cocoa Touch app. This will be written entirely in Swift, using the Xcode IDE.
Getting ready
Back in our existing CocoaTouch
project, in the File inspector, look for a folder called CocoaTouchTest
. Expand this and select the CocoaTouchTests.swift
file. Inside this file, you’ll notice a CocoaTouchTests
class, which, in turn, inherits from the XCTestCase
class. XCTestCase
offers a suite of functions that...