When you create a new project, Xcode creates a unit test target for that project with the name ProjectName
+ Tests
. If you are not familiar with unit testing, you can read about testing in Xcode at https://developer.apple.com/library/ios/documentation/DeveloperTools/Conceptual/testing_with_xcode.
Xcode will also create a simple unit test file for you. In our project, it's Swift_ToolkitTests.swift
. The unit test has three main methods, with different purposes:
setup
teardown
test
The names of these functions reflect their purposes. The setup
function performs additional setup before the unit test is run, and teardown
performs a cleanup, but the most interesting function for us is test
, which performs testing.
The XCTestCase
unit test class has a
measureBlock
function that works in a way similar to the measure
function that we...