A data model defines how objects in your application are constructed. In this video, see how to write your first unit test for your Movie data model.
- [Narrator] Since every movie in our app…will need at least a title, I think that's…a good starting point for our first test.…Underneath the tearDown function,…let's create ourselves some new lines,…and on line 24, let's start our first test function.…Func test, and then, Init_MovieWithTitle.…As far as naming goes, it's good practice…to be descriptive about what exactly…the test function is actually targeting,…usually with the context, and then, the result,…with an underscore in between.…
So here, we're testing the initializer of our MovieStruct,…and we're expecting it to return a movie with a title.…Now inside here, we need a new variable.…So, I'm going to say let testMovie = Movie,…and it's going to take in title,…and for this, I'm just going to say, "Generic Blockbuster".…Now, if writing that line of code felt weird,…it's totally normal.…Writing test-driven code is going to…feel backwards to most of you.…But one of the strengths of building your app…this way is it forces you to really consider…what it is you want your code to do at each step.…
- 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
Advanced iOS Development: Working with APIswith Saul Mora1h 59m Intermediate
Designing iOS and Android Appswith Renata Phillippi1h 6m 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.