SwiftUI Data & ArchitectureLesson 58Free preview
Testing SwiftUI
This lesson is part of Swift · All levels
Summary
This lesson discusses the automated testing strategy for SwiftUI applications. Developers will learn the differences between the Testing Unit to validate the ViewModel business function using the XCTest framework, as well as UI Testing to test user screen interaction flow automatically through button-touch simulation.
Key points
- The Testing Unit tests the functions, calculations, and logic of the ViewModel in isolation
- UI Testing simulates user interactions in real time using the XCUIApplication
- Assertive functions such as 'XCTAssertEqual()' and 'XCTAssertTrue()' validate the expectation of test results
- ViewInspector is a popular third-party library for performing unit tests directly on the SwiftUI view hierarchy
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.