Data models are subject to change, and our tests need to account for that. In this video, walk through expanding your data model and writing tests to accommodate these changes.
- [Narrator] There's nothing better than seeing a test pass,…so let's keep that going and add another one to…check that our movies can have a…title and an optional release date.…So underneath our testInit_MovieWithTitle…we're going to say func testInit_SetMovieTitleAndReleaseDate.…Now inside this test, let's declare a new Movie instance.…Let testMovie, the difference being that this Movie is…going to have, you guessed it, a title.…
We're going to say Romantic Comedy and a release date.…And this is also going to be a string just to…keep things simple.…Let's say 1987.…Now before we even run anything,…this is going to give us this same error again,…which is exactly what we want.…Now I know that sounds counterintuitive,…but in the red green refactor loop this just means that…we're going in the right direction.…Let's back in our project, let's go into our Movie struct,…and add a releaseDate property.…And this is going to be a string optional.…
Now it's optional because we don't necessarily…need all of our movies to have a release date since…
- What is test-driven development?
- Creating and expanding a data model
- Creating a manager class
- Testing class methods
- Checking for duplicates
- Testing table views
- Mocking cells
- Testing cell selection
- Assembling the app
Skill Level Intermediate
1. Foundation and Theory
2. Getting Started
3. The Manager Class
4. TableView Testing
5. Finishing Touches
- 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.