I am working in an ios app in Xcode 7.3.1.In that I am trying to start unit testing on my swift iOS app. I cannot see to access anything that uses my appDelegate.I tried the following to solve from the following.But still am getting the same issue.Please help me to solve this. link1, link2
I am getting the following issue,while i am running unit test. My sample code is
import UIKit
import XCTest
@testable import MyAppName
class FreshBossTests: XCTestCase {
var login:LoginPageController!
override func setUp() {
super.setUp()
login = LoginPageController()
}
override func tearDown() {
super.tearDown()
}
func testlogin() {
let email:String! = "xxx@gmail.com"
if login.isValidEmail(email) == true {
XCTAssertEqual(true, true,"email in valid format")
}
}
In my LoginPageController,I am having the following code.
let appDelegate:AppDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
In that line only am getting the error like
Could not cast value of type 'MyAppName.AppDelegate' (0x10dc09e80) to 'MyAppNameTests.AppDelegate' (0x11cc190c0).