I have 3 screens, lets say,
- Login
- Forgot Password
- Help screen
By default the Login screen open when the app starts. The Forgot Password screen is shown when you click on the Forgot Password button, and Help Screen opens when the Help link is clicked.
Can I somehow open the the Forgot Password Screen directly without going through the procedure of clicking the button using XCUITest?
I am suggesting something in the same lines as passing an adb intent to open a View directly.
As far as I know, you can't go directly to the second screen using XCUITest Framework. Anyway, documentation states:
Which means that if user of your app can't reach the second screen directly, why could your UI tests.
I know it's time consuming to wait to go to the second screen when you run your tests, but you can bypass writing it for every test. To write it only once, in your XCTestCase class write a function where you implement calling a second screen and call that function in
setUp()
method. Then, the process of skipping the first screen will be called every time you run a test becausesetUp()
method is called before every test run.EDIT
After reading your comment, I could think of one hacky solution. You can communicate with your app from your tests using Launch Environment and/or Launch Arguments. So, in your XCTestCase class, set up argument and environment:
Then, in your ViewController, write these computed properties:
And in
viewDidLoad()
method, you can have something like this:Note: this is a really dirty hack and it is not recommended way of writing UI tests.