func testExample() {
let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
// some code ...
}
The above function always crash and gives this error:
Could not cast value of type 'MyAppName.AppDelegate' (0x10dc09e80) to 'MyAppNameTests.AppDelegate' (0x11cc190c0).
You are probably compiling AppDelegate into your test target. Don't do this.
Instead, only compile into your normal app target MyAppName. In you test class write in XCode 7
@testable import MyAppName
and before XCode 7
import MyAppName
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With