TESTING

An App With SCA: State Testing

How to test the state of your SwiftUI and Composable Architecture app.

Riccardo Cipolleschi
7 min readOct 7, 2020

--

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!

Create a test project.

--

--

Riccardo Cipolleschi

Hey there, I’m Riccardo. Software engineer at Meta. I have a passion for iOS and I love to share my knowledge with others.