
Member-only story
TESTING
An App With SCA: State Testing
How to test the state of your SwiftUI and Composable Architecture app.
This is the fourth article of a series. These are the previous articles:
Welcome back to another article on the Composable Architecture. Today I’d like to explore how to test the state updates of our app.
Testability is one of the pillars of the Composable Architecture by pointfree.co: this concept is so important that they created a whole sub-framework called ComposableArchitectureTestSupport
that is already shipped within the Composable Architecture.
The TestSupport is built on top of the ComposableArchitecture
and the Apple XCTest
framework. In this way, we don’t need to download any other dependency to test our code.
Which unit of our code should we test? The architecture pushes toward implementing the whole app logic in one or more reducers. Therefore the object that must be tested, to ensure that the app is behaving properly, is the reducer itself!
Let’s see together how can we do that!