Testing the data source of a table view
In this section, we will implement parts of the data source for the table view using test-driven development. We will use the traditional approach by using the view controller as the data source. In the next section, we will switch to a diffable data source. Our challenge in this section is to write the tests so that they are independent of the actual implementation of the data source.
But first, we need to talk about test doubles.
Adding a test double
In the film industry, doubles are used in scenes that are too dangerous for the actor. The double must look and act like the actor. In software testing, we have something similar: test doubles. Test doubles look and act like a piece of code, but can be controlled completely from within the test. For example, to test the data source of our table view, we need to connect the view controller with a store of to-do items. We could use the store we already implemented. But this would make the...