- Hands-On Server-Side Web Development with Swift
- Angus Yeung
- 194字
- 2021-06-10 19:00:21
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:
- The AppTests class is inherited from XCTestCase
- The testNothing() function with the prefix test will be executed
- Icons will show whether or not AppTests and testNothing() have been executed successfully
- 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.