From the course: iOS App Development: Test-Driven Development

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Create a data model

Create a data model

From the course: iOS App Development: Test-Driven Development

Start my 1-month free trial

Create a 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…

Contents