Created
June 5, 2015 16:27
-
-
Save netbe/991191be55a1ef11c2d7 to your computer and use it in GitHub Desktop.
AppDelegate UnitTests Swift
This file contains 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
// AppDelegate.swift | |
import UIKit | |
func isRunningTests() -> Bool { | |
let environment = NSProcessInfo.processInfo().environment | |
if let injectBundle = environment["XCInjectBundle"] as? NSString { | |
return injectBundle.pathExtension == "xctest" | |
} | |
return false | |
} | |
@UIApplicationMain | |
class AppDelegate: UIResponder, UIApplicationDelegate { | |
override init() { | |
super.init() | |
if (isRunningTests()){ | |
// This bundle has unit tests injected. Let's not really start the app to avoid interfering with the tests. | |
let infoDictionary:NSDictionary = NSBundle.mainBundle().infoDictionary! | |
infoDictionary.setValue("UnitTests", forKey:"UIMainStoryboardFile") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment