Mocking CLGeoCoder
CLGeoCoder
is a class provided by Apple that helps you to get coordinates from an address string and vice versa. The methods in CLGeoCoder
are based on completion closures. In this chapter, we will explore how to mock and test such methods.
Cleaning your project
Before we write the first test for this chapter, let's clean up the project a bit. Add sections in the project navigator and move the files to those sections according to your structure scheme. For inspiration, here is the structure I use for the main target:
Your structure can be completely different. Use the structure you usually use in iOS projects. Also, add a similar structure to the files in the test target.
When you add new files to the project, you have to choose the correct folder depending on the structure you applied.
Preparations for the tests
Before we can write tests for the APIClient
...