S01E10: [TDD 🍅 9] Testing Table View Cells in Swift

In this episode, we continue the implementation of ResultsViewController by test-driving the configuration of the cells.

As we showcased in episode 6, the behavior and the layout of a view are two separate things, which can be tested and implemented independently. The cell configuration showed in this episode is no different as we test the behavior and defer the appearance for later.

As we test-drive the behavior of ResultsViewController, we are adding more properties to the PresentableAnswer. To prevent breaking any tests that already create a PresentableAnswer, we use a factory method with default parameter values. This refactoring decouples the creation of an instance of PresentableAnswer from the values we would like to create it within the tests, resulting in less fragile and more readable tests.

Small and frequent improvements in our disciplines allow us to influence our team and increase the value we provide across the company.

Subscribe now to our Youtube channel and catch free new episodes every week and follow along the project's progress on GitHub.