I'm doing Unit Tests in Swift, and am running into a problem. Every time I run the tests, I get the error:
Could not cast value of type 'app.AppDelegate' to 'app_Tests.AppDelegate'
I made sure that the AppDelegate was unchecked from the tests bundle, and the view controllers cannot access the app delegate anymore. Does anyone have a solution to this problem. Thanks in advance!
I think your view controllers
has checked target membership
in your test bundle. In this case you view controllers
uses your tests module and App Delegate your real module.
If you have in your test file @testable import <module name>
in the top, where your app name, for example app
. Then you should have ability to your view controllers
without checked target membership
for your tests.
This thing comes with Swift 2.0 that was released in September 2015.
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