From the course: iOS App Development: Test-Driven Development
Unlock the full course today
Join today to access over 22,500 courses taught by industry experts or purchase this course individually.
Expand the data model
From the course: iOS App Development: Test-Driven Development
Expand the data model
- [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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.