In this video, Mark DiFranco writes unit tests for the sample project's location permission class in Xcode. Learn how to take advantage of the setup method to reset the state before each test. Take a look at some good habits to form when choosing which tests to write. Then, implement the tests, adhering to the formatting outlined in previous videos.
- [Instructor] Now we're finally set up to start…writing some tests.…Let's start by writing tests for the location…authorization class.…In speedometer test group, we can close the mocks…group now, and we'll create a new group for location.…This will mirror the structure of our speedometer group.…Once again we can click on the folder icon in the…right panel, and we'll create a new folder for location.…
Inside the location group, let's right click and add…new file.…Instead of adding a swift file, let's select the…unit test case class.…We'll click next, and we'll name the…class SPDLocationAuthorizationTests.…Then we can click next, and we'll add it to the…location group.…So you can see we have some boilerplate code here.…We can remove everything except for the setup method.…
Now let's take this comment out as well.…Let's start off by doing a testable import of our…speedometer target.…First thing we want to do is set up our sut.…We'll define a variable at the top of our test file.…We'll make it an SPDLocationAuthorization.…
- Why write unit tests?
- What is dependency injection?
- Using protocols to help with tests
- Handling external dependencies
- Anatomy of a test case
- Writing tests
- Analyzing code coverage
- Visualizing test results
- Writing and extending UI tests
Skill Level Intermediate
Core Data for iOS and macOS Enterprise Developerswith Jon Bott1h 46m Intermediate
Learning Server-Side Swift with Vaporwith Ron Buencamino1h 30m Intermediate
Swift 3 Essential Training: Beyond the Basicswith Scott Gardner2h 58m Intermediate
1. Dependency Injection
2. Using Protocols
3. Writing Tests
4. UI Tests
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.