Mohammad Azam
Jan 2, 2024

--

I have used several techniques for testing view logic in SwiftUI. Few of them you already mentioned.

1. ViewInspector

2. Xcode Previews (Yes manually testing my view)

3. Structs (If views have complicated logic then I can extract logic into a struct and then test the struct).

4. End to end testing - These kind of tests are perform to test a long scenario/feature. So my test may be "As a user I should be able to login and then add two grocery categories each with 2 items and then delete them". These are best tests since they test how users will actually use the application. They take time to write and they are slow but because they actually do a lot of work.

--

--

Mohammad Azam
Mohammad Azam

Written by Mohammad Azam

Lead instructor at a coding bootcamp. Top iOS mobile instructor on Udemy. Author of multiple books and international speaker. azamsharp.school

No responses yet