mobileiq / miq-ios-testingframeworks

iOS Unit testing frameworks

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MIQTestingFrameworks

An iOS framework including prebuilt unit testing libraries including:

  • expecta Simple expectations framework
  • OCMock Objective-C mock framework. Solid but limited
  • LRMocky Objective-C port of jMock. Fuller featured, but not as battle hardened
  • OHHTTPStubs Network stubbing library

Other features

The MIQTestingFramework.h header contains headers for all frameworks built in as well as any helpful test classes in the library. It also includes the TEST_CASE and TEST_CASE_WITH_SUBCLASS macros.

Included classes

MIQCoreDataTestBase is a simple base class for unit testing Core Data functionality. It finds the model contained in your main bundle and creates an in-memory persistent store. Use the managedObjectContext property to pass in to your Core Data dependent classes and methods.

Building from Source

For reasons of my own sanity, it proved easier to add some of these libraries as cocoapods dependencies rather than submodules. You'll need to make sure you've got cocoapods installed (gem install cocoapods followed by pod setup).

Once that's done, run pod install. You'll also need to update the submodules (git submodule update --init). You can then open MIQTestingFramework.xcworkspace. Note workspace not project. Then build the Framework target. You'll find the built framework in the root of your built products directory.

I suggest you build the framework and then add it as a binary to the project you wish to test rather than trying to add it as a submodule.

Using the framework

You need to add -ObjC and -all_load to Other Linker Flags. If you use the MIQCoreDataTestBase you may need to link your unit test bundle to CoreData.framework. Then simply add #import <MIQTestingFramework/MIQTestingFramework.h> to your test or to your test bundle's PCH file and have all the fun in the world.

xcodetest

xcodetest is also included here as a submodule, as this seems to be a simple and quite clever way to run your unit tests from the command line. Simply follow the instructions in the readme file. If you're using a workspace, you may need to copy and edit the bash script. Again, copy the dependencies to your project.

About

iOS Unit testing frameworks


Languages

Language:Objective-C 82.0%Language:Shell 17.5%Language:Ruby 0.5%