Created
September 26, 2025 14:20
-
-
Save omidgolparvar/0caa2340bf5afa60714e7e24852671e7 to your computer and use it in GitHub Desktop.
Custom AppDelegate for Tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// https://www.linkedin.com/posts/jacobmartinbartlett_advanced-ios-testing-speed-up-your-tests-activity-7375121681171849216-2gSg | |
| import UIKit | |
| private func isRunningUnitTests() -> Bool { | |
| NSClassFromString("Testing.Test") != nil || | |
| ProcessInfo.processInfo.environment["XCTestBundlePath"] != nil | |
| } | |
| let appDelegateClass: AnyClass = if isRunningUnitTests() { | |
| UnitTestAppDelegate.self | |
| } else { | |
| AppDelegate.self | |
| } | |
| UIApplicationMain( | |
| CommandLine.argc, | |
| CommandLine.unsafeArgv, | |
| nil, | |
| NSStringFromClass(appDelegateClass) | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment