Testing in iOS - Part 16: Mocking | Ray Wenderlich

There are times in your testing when you'll need to create objects that pretend to be other other objects. This is called mocking.

This is a companion discussion topic for the original entry at https://www.raywenderlich.com/3530-testing-in-ios/lessons/16

This video moves very fast - the author often speeds up the video to type their code faster. I’m not sure how I’m supposed to keep up. I had to rewind the video several times.

When refactoring the HTTPClient() class, around 4:42 a few changes are made to the class at one time, using a visual transition in the video. But you don’t get more than a second before they move to a different class.

I had to download the course material for this particular video in order to figure out what was missing from my code.

Were you able to figure out the missing code? Cheers!

Yes, I figured it out. I had to download the course material for this particular video and compare.

1 Like

There was one error in the starter directory that the storyboard scene for the information View ViewController was not named correctly. It was given the storyboardID “infoView”. I got an error while running the starter project and clicking on the Information button.

Looking at the error, I changed it to “InformationView” and it worked fine.

If the video is too fast for you to follow along, you can also play it at half-speed.

There are an issue when refactor the init method of HTTPClient at 4:20 adding the session, the old initialization of shared variable

static let shared = HTTPClient()

is now broken, useless and it must removed.
It is not shown in the video.

Sounds like the video is out of date. I’ll make sure the next instructor knows about this. Thanks!