Snapshot testing SwiftUI views
Snapshot testing is another name for characterization testing. Here's the definition by Michael Feathers, the guru of improving legacy code: https://michaelfeathers.silvrback.com/characterization-testing. In the SwiftUI implementation, we are taking a snapshot of the current component we want to preserve, and we run a test against that component so that if in the future someone mistakenly changes its appearance, the test will fail.In the case of iOS, usually a component we want to preserve is
UIViewController or a
Depending on the library we are going to use, we can take the snapshot in different ways: as a textual description or an actual screenshot. For this recipe, we'll use the Swift Snapshot Testing library that you can...