S01E19: [TDD 🍅 16] Testing Concrete Factories in Swift
/In this episode, we finish test-driving the QuestionViewController
creation in the concrete view controller factory.
We discuss the importance of TDD and design by contract when defining architectural boundaries, since we have to decide what to do when a wrong setup prevents us from creating a view controller. To avoid polluting the abstract factory with lower level details of the concrete implementation, we decide to raise a fatalError
, since that would be a clear violation of our protocol contract.
Finally, we reflect on how to proceed with testing the results view controller creation, without having a Presenter
implementation yet. We decided to defer the factory implementation to build a concrete Presenter
first, instead of creating a protocol and mocking a Presenter
implementation to use in the tests, since it seems excessive to add another level of indirection to our design.
Subscribe now to our Youtube channel and catch free new episodes every week and follow along the project's progress on GitHub.