iOS Interview Prep 12 — Snapshot Test

Xiao.J
iOS Interview Prep Guide
4 min readAug 8, 2023

--

The purpose of this interview preparation series is to assist you in quickly refining your interview skills and thoroughly preparing for the typical questions asked during an iOS interview. If you find it useful, please leave a comment or tap the like button.

Photo by Minh Pham on Unsplash

Overview

Writing tests for the visual aspects of an app is always challenging. It’s very straightforward to test logical parts but less obvious how to test your UI. This is the reason why so many developers leave their view without testing or investing much effort into UI testing. Apple provides frameworks to help us test logic units, but when it comes to testing the end result of what the user actually sees there’s not much support. Snapshot tests help us solve these issues, it’s easy to set up and write view-based tests.

Why Snapshot Test?

iOS developers write lots of UI code, if you want to test the UI through code it’s almost impossible due to the number of states and corner cases even for a simple UI. Snapshot testing is easy to integrate into your project, it allows us to verify the high-level appearance of views. Each snapshot is compared to the previous version to prevent visual regressions.

The normal workflow to test your UI changes

  1. Build the app

--

--

Xiao.J
iOS Interview Prep Guide

Ex-Meta with 10+ years of experience in iOS Development 