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.

Mocking the TableView cell

Mocking the TableView cell

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

Start my 1-month free trial

Mocking the TableView cell

We're going to move on to testing our TableView cell right now, which is normally a no-brainer, right? We create a cell, we hook it up, and we configure it with our data. But because we're starting to test out the TableView functionality, we're going to introduce the concept of mocks. Now, in essence, mocks are exactly what they sound like: a mock-up or stand-in for the real thing in our app. We're going to be using mocks pretty heavily from now on, so it's a good time to get really familiar with the topic. So while we're still in our library data service tests, let's add a new pragma mark, and we're going to call this Cells, and let's start off with a new func testCell_RowAtIndex_ReturnsMovieCell. Now, inside this test, we're just going to call sut.movieManager.addMovie. We're going to add in darkComedy, and we're going to reload our table view, so libraryTableView.reload, and finally, we need to pull out the new dequeued cellForRow, so let cellQueried = libraryTableView.cellForRow…

Contents