title: Cannot cast App Delegate to App Delegate in XCTest
body: <p>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.
  <a href="https://stackoverflow.com/questions/28042105/swift-dynamic-cast-failed-error-when-trying-to-run-unit-tests">link1</a>,
  <a href="https://stackoverflow.com/questions/31179382/cannot-access-appdelegate-while-testing-xcode-project">link2</a></p>
  
  <p>I am getting the following issue,while i am running unit test.
  My sample code is</p>
  
  <pre><code>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")
          }
      }
  </code></pre>
  
  <p>In my LoginPageController,I am having the following code.</p>
  
  <pre><code>let appDelegate:AppDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
  </code></pre>
  
  <p>In that line only am getting the error like </p>
  
  <pre><code>Could not cast value of type 'MyAppName.AppDelegate' (0x10dc09e80) to 'MyAppNameTests.AppDelegate' (0x11cc190c0).
  </code></pre>