MENU

Fun & Interesting

Testing 101: What Are UI Tests & How to Write Them in Swift/iOS

Swift and Tips 2,065 6 months ago
Video Not Working? Fix It Now

In this episode of Testing 101, we explore UI tests and explain how they differ from other types of testing. While unit tests focus on individual components, UI tests ensure that the user interface behaves correctly as a whole. I’ll walk you through a real-world demo, setting up a UI test in Xcode, simulating user actions, and making your tests more reliable by mocking a Web API call. Content: 0:00 - Intro 3:02 - UI Test Target 6:11 - UI Test File from Template 7:22 - App Object 8:27 - Recording a UI Test 11:07 - Creating Identifiers 15:51 - waitForExistence 17:35 - ProgressView not detected 19:46 - Cells in UI Tests 23:18 - Labels as Identifiers 23:59 - Simulating user actions 26:41 - Recording UI sometimes fails. 29:10 - CartList’s Alerts and Views 32:09 - Fails in UI Test 34:00 - Mocking UI Test 42:25 - Fixing unexpected issue with alert 47:13 - UI Tests are expensive! 48:57 - BONUS: Testing Error Flows 50:00 - Outro Demo: https://github.com/pitt500/OnlineStoreMV/tree/ui-test-demo --- * What is a Unit Test?: https://youtu.be/_fKa0oLV3Zk * What is an Integration Test?: https://youtu.be/Sp0CK39ehsQ * setUp & tearDown: https://youtu.be/a9mF6eNcprI * Swift Testing Playlist: https://www.youtube.com/playlist?list=PLHWvYoDHvsOV67md_mU5nMN_HDZK7rEKn * SwiftUI Modifiers: https://youtu.be/QJJYDawfugk ----- Other videos from my channel: * Podcast: https://www.youtube.com/playlist?list=PLHWvYoDHvsOX_radIYARFZ-nUSkhv_Ur3 * Swift Concurrency: https://www.youtube.com/playlist?list=PLHWvYoDHvsOUsGazZVW_ZdehusA0diIxs * any Protocol (Existential Types): https://youtu.be/Wa8xTSHX_PM * The Composable Architecture (TCA): https://www.youtube.com/playlist?list=PLHWvYoDHvsOVo4tklgLW1g7gy4Kmk4kjw * Apple Watch Layout using Geometry Reader: https://youtu.be/ma4LP8RnyI0 * Key Paths: https://youtu.be/LaoTqDiqOiA * Result Builders to build a web framework: https://youtu.be/kZ7JPFUVv1w * Types of Access Control: https://youtu.be/MPXvleREPe0 * Generics: https://www.youtube.com/playlist?list=PLHWvYoDHvsOVP-9UvMBBYJCqxrJ3E8Cry ----- My Contact: https://www.swiftandtips.com https://twitter.com/swiftandtips https://iosdev.space/@swiftandtips https://www.linkedin.com/in/pedrorojaslo/

Comment