🎉 End-of-year Sale! Save 25% when you subscribe today.
An architecture is only as strong as its testability, and the Composable Architecture is incredibly testable. We are able to unit test every part of the architecture, including the core types that features are built with, the side effects that interact with the outside world, and the runtime that glues everything together to actually power the application.
The Composable Architecture also unlocks some incredible ways to perform snapshot testing in SwiftUI. We are able to use the Store
to play a series of user actions, and then take snapshots of the UI at each step of the way. This gives us lightweight integration testing of our UI with very little work that rivals the tools that Xcode gives us out of the box.
In this section we used the “environment” technique for controlling dependencies that we first covered in the early days of Point-Free. It eschews using protocols for dependencies and just uses simple structs, which gives us a lot of flexibility.
Although the “environment” technique of dependency injection is powerful, and can help you get test coverage in an application almost immediately, we can make it even better in the Composable Architecture. By baking the notion of an environment directly into the core types of the architecture we will make our dependencies more controllable and more understandable, all without sacrificing composability.
The Composable Architecture is now quite robust and handles many things that are important to real life applications, such as composition, modularity, side-effects and testing. With this foundation set we can now look for ways to take the architecture to the next level.