Hands-On Server-Side Web Development with Swift
上QQ阅读APP看书,第一时间看更新

Running unit tests in Xcode

Xcode automatically scans all of your XCtestCase tests with a prefix of test, for example, testNothing(), and links them to a specific test target. You can use a new scheme configured by Xcode to use that target and run it within Xcode.

In Xcode, use + U or select from the menu Product | Test to run the tests in this test target:

The highlighted numbered sections in the image have a specific role.These roles are listed here: 

  1. The AppTests class is inherited from XCTestCase
  2. The testNothing() function with the prefix test will be executed
  3. Icons will show whether or not AppTests and testNothing() have been executed successfully
  4. You can also run an individual test using the test's play button in Test Navigator

Use Test Navigator to give you an overview of all the available tests in a test target. It has a play button next to each individual test; you can choose to run a specific test individually.

Check the results of your test runs. In Xcode's console window, it prints out how many tests were run and how many of them failed.