3

I'm writing XCTest app tests that test some UIViewControllers by calling presentViewController on the UIApplication rootViewController.

This works fine, except for permissions dialogs. Some of the UIViewControllers make the system pop permissions dialogs for things like camera or microphone access. I'm not sure how to dismiss them.

If this were a UI test, I could use addUIInterruptionMonitorWithDescription and tap the alert away.

However, I'm not sure how to make this work. Can an app test access UI test features?

paleozogt
  • 6,393
  • 11
  • 51
  • 94
  • 1
    Hi, did you figure out a way to resolve the issue ? – DrPatience Jul 14 '17 at 09:08
  • It appears we need to use Dependency Injection (DI) and/or Mock classes to accomplish this. This [Lynda.com course](https://www.lynda.com/iOS-tutorials/Swift-Writing-Testable-Code/590829-2.html), released 5/24/2017 at last view, discusses both. (The course may be available for free as an intro to Lynda.com or through your local library.) – leanne Dec 05 '17 at 18:59

1 Answers1

1

In xcode ui test, to access system pop permissions dialogs, use the below code:

self.addUIInterruptionMonitorWithDescription("your alert text", handler: { (alert) -> Bool in
     yourAlertElement.tap()
     return true
     })

Hope this will help and if you have any confusion, let me know.

noor
  • 2,954
  • 2
  • 16
  • 29