I want to access a particular property router
from the App Delegate of the launched app during a UI Test, but I can't figure out if this is possible or not. I have tried:
let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
let router = appDelegate.router
but this gives a failure and won't even build. I am using @testable
on my project module. Any ideas?
Xcode UI testing is designed such that the test code can only see what a user can see, so no objects from the application under test can be used or inspected in the test code. This is also why the views on the screen are represented as XCUIElement objects instead of UIView descendants.
The UI tests run in a separate executable from the application under test. The only way to communicate additional information from the app to a UI test is by constructing a string containing the information and using it as the accessibility identifier for an element.
If you want to test something that requires access to an object from the application code, it is most likely that you need to write a unit test instead of a UI test.
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