The question has been changed to OS X, so my answer is no longer valid
Original answer
It's impossible. The main reason is that the tests are associated with one running instance of the application, they have no control over the device, they work as part of the application. You can probably open the URL, but you will not be able to return to the application and complete the approval.
Also note that XCUnit is a unit . You cannot write an advanced integration test into it. You may have done better in UI Automation, but this particular test case will be very difficult even for him. For example, to open a link with your application in the simulator, you can create an HTML page that will be redirected to the link, and then use the shell for exec open testLink.html -a "iOS Simulator" . However, in my humble opinion, such tests are unreliable and very difficult to write and debug.
My advice:
- Write a unit test that mocks
[UIApplication openURL:] and make sure you pass it the correct URL. Or if you want a different direction, write unit test, which will call the UIApplicationDelegate methods in the called order, simulating the opening of a link by your application. This is as far as possible with XCUnit. - Check the rest manually.
Sulthan
source share