Skip to content

MrNickBarker/NLBaseTests

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NLBaseTests

Unit testing base class for iOS. XCTestCase subclass that makes notification observing testing easy.

More info: https://blog.codecentric.de/en/2014/09/unit-testing-notification-observing-ios/

Usage

Your test case should inherit from NLBaseTests

Objective-C

NLAssertObservingNotification(obj, notifcation, description, ...);
NLAssertObservingNotificationWithSelector(obj, notification, selector, description, ...);
NLAssertNotObservingNotification(obj, notification, description, ...);

Swift

NLAssertObservingNotification("notificationName", object: obj, description: "I forgot to observe")
NLAssertObservingNotificationWithSelector("notificationName", object: obj, selector: "testSelector", description: "I forgot to observe a selector")
NLAssertNotObservingNotification("notificationName", object: obj, description: "I forgot to stop observing a selector")

check the included example projects for more details.

Installation

Objective-C

  • Add the NLBaseTests folder to your project and select your unit tests as the target.
  • Remove NLBaseTests\NLBaseTests.swift from your project as it is not needed.

Swift

  • Add NLBaseTests\NLBaseTests.h and NLBaseTests\NLBaseTests.m to your project and select unit tests as the target. Note: don't add the whole folder because you will have to do the next step manually.
  • Confirm when Xcode asks you if you want to create a bridging header
  • In the unit tests target build settings make sure that Objective-C Bridging header is pointing to the correct file
  • Add NLBaseTests\NLBaseTests.swift to your project and select unit tests as the target
  • In the bridging header #import "NLBaseTests.h"

About

iOS - SenTestCase subclass that makes notification observing testing easy

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published