I am writing a framework that wraps UILocalNotifiations
, and in the processes of writing unit tests for it. It's actually more of a functional test, but whatever.
So, the test I am trying to write is:
func testAlertManagerCanRegisterLocalNotifications() {
let manager = Manager()
manager.alerts = DummyAlerts
let app = UIApplication.sharedApplication()
let scheduledNotifs = app.scheduledLocalNotifications ?? []
XCTAssertEqual(scheduledNotifs.count, manager.alerts.count)
}
Given that the manager synchronously schedules UILocalNotifications
when the alerts
property is mutated, this test should pass .. but it doesn't.
The root cause here is that the tests don't have the necessary permissions to schedule notifications, and I have no idea how am I suppose to allow the test app these permissions? After all, there is no UI involved.
The Question:
Is it possible to force the test app to have the necessary UIUserNotification
permissions?