ios - UNUserNotificationCenter unit tests -


i try test simple method supposed create , deliver notification ios 10.

func displayplacenotificationcontent() {     let unmutablenotificationcontent = generatenotification()     let trigger = untimeintervalnotificationtrigger(timeinterval: 1, repeats: false)     let request = unnotificationrequest(identifier: getnotificationidentifier(), content: unmutablenotificationcontent, trigger: trigger)     let notificationcenter = unusernotificationcenter.current()     notificationcenter.add(request, withcompletionhandler: nil) }   

and here unit test of method:

func testdisplaynotification() {     notificationmanager?.displayplacenotificationcontent())     xctasserttrue((notificationmanager.isnotificationdisplayed()) } 

when try execute unit test have exception, stacktrace:

2017-09-12 13:52:25.931564+0200 xctest[17170:1252988] *** assertion failure in -[unusernotificationcenter initwithbundleproxy:], /buildroot/library/caches/com.apple.xbs/sources/usernotifications_sim/usernotifications-156/unusernotificationcenter.m:50 2017-09-12 13:52:25.933629+0200 xctest[17170:1252988] *** terminating app due uncaught exception 'nsinternalinconsistencyexception', reason: 'invalid parameter not satisfying: bundleproxy != nil' *** first throw call stack: (     0   corefoundation                      0x000000010b0a9aeb __exceptionpreprocess + 171     1   libobjc.a.dylib                     0x000000010aa0cf41 objc_exception_throw + 48     2   corefoundation                      0x000000010b0aebb2 +[nsexception raise:format:arguments:] + 98     3   foundation                          0x000000010a381d06 -[nsassertionhandler handlefailureinmethod:object:file:linenumber:description:] + 193     4   usernotifications                   0x000000010bff8c99 -[unusernotificationcenter initwithbundleproxy:] + 297     5   usernotifications                   0x000000010bff8a6f __53+[unusernotificationcenter currentnotificationcenter]_block_invoke + 81     6   libdispatch.dylib                   0x0000000111a39475 _dispatch_client_callout + 8     7   libdispatch.dylib                   0x0000000111a3a909 dispatch_once_f + 55     8   usernotifications                   0x000000010bff8a1b +[unusernotificationcenter currentnotificationcenter] + 45 ... 

the responsible line failure supposed access of unusernotificationcenter current() method. don't see why? unusernotificationcenter supposed singleton, can't use in unit test context? supposed mock it?


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -