I'm trying to use unit test in swift to test some of the real application behaviour.
When i try to cast de UIApplicationDelegate
to my AppDelegate
from my test function i got and EXC_BAD_ACCESS exception. Below the test code:
func testGetAppDelegate(){
let someDelegate = UIApplication.sharedApplication().delegate
let appDelegate = someDelegate as AppDelegate //EXC_BAD_ACCESS here
XCTAssertNotNil(appDelegate, "failed to get cast pointer")
}
AppDelegate class is set to public so it is not a problem from access level.
Using objective-c in the same test target it works. Below the simple instruction:
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
The debuger says someDelegate is a Builtin.RawPointer. Don't know what that is, i am not familiar with low level details.