It goes without saying that testing plays a massive part of the software development life cycle. Primarily, a lot of the focus is on physical user testing – putting your piece of code in the hands of those using it day in day out. To a degree, 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 codebase?
This is where unit and integration testing comes 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 class named CocoaTouchTests, which, in turn, inherits from the XCTestCase class. XCTestCase offers a suite of functions...