I think you added AppDelegate.swift
to the tests target members.
When you do that, AppName.AppDelegate
and AppNameTests.AppDelegate
becomes different classes. Then, UIApplication.sharedApplication().delegate
returns AppName.AppDelegate
instance, but you are trying to cast it to AppNameTests.AppDelegate
type. That causes EXC_BAD_ACCESS
.
Instead of that, you have to import it from your application module.
import UIKit
import XCTest
import AppName // <- HERE
class AppNameTests: XCTestCase {
// tests, tests...
}
And, AppDelegate
class and its methods and properties must be declared as public
to be visible from test module.
import UIKit
@UIApplicationMain
public class AppDelegate: UIResponder, UIApplicationDelegate {
public var window: UIWindow?
public func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
return true
}
// ...
Again, Be sure to remove AppDelegate.swift
from the Test target members.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…