Monday Dec 23, 2019
SwiftUI is an incredible technology for building UI that is going to drastically change the way we build iOS applications. In UIKit we manage views by coordinating a bunch of mutable objects, but SwiftUI allows us to avoid all of those messy details by providing a declarative framework that lets us simply describe the view hierarchy.
However, since we are still in the early days of this technology, it is not yet clear how we are supposed to test a SwiftUI application. Almost everything that happens in a SwiftUI View
is hidden from us, and so it can be hard to make assertions on logic that is happening inside the view.
Luckily there’s a very simple way to get broad test coverage on any SwiftUI view today, and it’s done using the snapshot testing library we open sourced one year ago!
In this week’s free episode we demonstrate how to add SnapshotTesting to the application we have been building over the past many weeks. We show off lots of really cool things:
UIHostingController
.UIWindow
.If you find any of this interesting, hop on over to our 100% free episode demonstrating how all of this (and more) is possible!
👋 Hey there! If you got this far, then you must have enjoyed this post. You may want to also check out Point-Free, a video series covering advanced programming topics in Swift. Consider subscribing today!