This is a quick post about a new feature added by Apple in Xcode8.3 that let me test an edge case through UITests.
Let’s consider to have a business logic only applied when the app is resumed from background. And let’s say that if the app is resumed from background then your app navigation changes due to your business logic.
Until XCode8.2 every time a new UITest is executed, the app process is killed and the app is executed from scratch.
Browsing the Apple doc I’ve noticed that they have added the access to Siri through XCUIDevice and the only method exposed by it is:
This let me to simulate the flow in which the user puts the app in background (using the Home button) and then resumes the app using Siri.
I’ve created this sample project on github in which I’ve implemented a really smart logic:
1. if the app is executed from scratch and the user clicks on the button --> show an amazing popup
2. if the app is resumed from background and the user clicks on the button --> push a view controller
Well basically these two cases are summarized in this little tiny code:
That’s it! With Xcode 8.3 you can improve your UITests using Siri, for instance testing custom actions sent from it to your app!