To run the example project, clone the repo, and run pod install from the Example directory first.
Then, navigate to NSNotificationCenterMock_ExampleTests/NSNotificationCenterMock_ExampleTests.swift and see how the test case utilises NSNotificationCenterMock to test the example app.
NSNotificationCenterMock is available through CocoaPods. To install it, simply add the following line to your Podfile for your testing target:
target 'YourAppTests' do
pod 'NSNotificationCenterMock'
endNSNotificationCenterMock provides the following public methods:
hasRegisteredNotificationName(name:_, withSelector:_) -> Bool- Returns whether an observer has been registered for NSNotification
namewith target selectorwithSelector.
- Returns whether an observer has been registered for NSNotification
hasNotificationBeenPosted(notificationName:_) -> Bool- Returns whether a NSNotification named
notificationNamehas been posted.
- Returns whether a NSNotification named
timesNotificationPosted(notificationName:_) -> Int- Returns how many times a NSNotification named
notificationNamehas been posted.
- Returns how many times a NSNotification named
registeredNotifications() -> Int- Returns how many notification the observer has registered too.
hasRegisteredNotifications() -> Bool- Returns a boolean indicating whether the observer has registered to any notifications or not.
attheodo, [email protected]
NSNotificationCenterMock is available under the MIT license. See the LICENSE file for more info.