Any leads how can we use Snapshot testing to test darkmode implementation? Or any other testing strategy for dark mode on iOS.
When XCUITest is one of the options along with XCTest (unit-test). The problem with UITest in dark mode means for every app flow it needs to be run twice.
Will Unittest cases be enough to suffice testing needs for dark mode? Can you think of any use case which won't be covered using only unit testing for dark mode?
I use FBSnapshotTestCase to get light & dark snapshots in a unit test target:
This produced the following snapshots:
The tricks were:
usesDrawViewHierarchyInRect = true
on the snapshot test caseoverrideUserInterfaceStyle
on the view controllerThe usual advantages of snapshot tests over UITests apply. Snapshots are slower than normal unit tests, but much faster than UITests because we don't have to navigate through the app to reach each view controller.
How fast? Here's my timing, running on a 2015 MacBook Pro.