SwiftUI Unit Testing Setup Made EASY
Автор: StemFoxIO
Загружено: 2025-10-13
Просмотров: 53
How to unit test in SwiftUI. Learn how to properly setup you SwiftUI app for unit testing.
Watch This Next: • Find Memory Leaks FAST using Swift Testing!
Code:
Add this code in a new file or to your `AppNameApp.swift` file to isolate your app code during unit testing.
```
@main
struct AppLauncher {
static func main() throws {
if NSClassFromString("XCTestCase") == nil {
Your App's App Name.main()
} else {
TestApp.main()
}
}
}
struct TestApp: App {
var body: some Scene {
WindowGroup { Text("Running Unit Tests...") }
}
}
```
Video Links
main()
https://developer.apple.com/documenta...)
Connect with me!
X: https://x.com/StemFoxIO
Question - Do you unit test your apps? Answer in the comments!
Want to learn more? Here are some sources I've learned from. Plus, some purchases help the channel (Affiliate Links).
I love Big Mountain Studio's books. Detailed and image oriented. Check them out here https://www.bigmountainstudio.com/a/y...
⏰ Timecodes ⏰
00:00 - Intro
00:08 - Issue with unit testing SwiftUI
02:11 - Creating a test application
02:56 - Creating the AppLauncher
04:35 - Benefits of a test app
#swift, #ios #development, #software, #swiftui, #unittests
About:
StemFoxIO posts videos to help you become a better, more efficient iOS developer.
Доступные форматы для скачивания:
Скачать видео mp4
-
Информация по загрузке: