Skip to content

Various helper classes to assist when testing for iOS and Mac OS X

Notifications You must be signed in to change notification settings

runloop/ILTesting

 
 

Repository files navigation

ILTesting

ILTesting provides a collection of Objective C helper classes primarily for assisting with testing. That is, if you can call the current content of one class a collection.

ILCannedURLProtocol

ILCannedURLProtocol is intended for unit and mock testing of code that makes http requests. It will intercept the standard http protocol and respond with a predefined set of test data every time the test is executed. This way any outside influences can be eliminated from the test results.

In order to use ILCannedURLProtocol, insert the following code in your test case before executing the code under test:

[NSURLProtocol registerClass:[ILCannedURLProtocol class]];
[ILCannedURLProtocol setCannedStatusCode:200];
[ILCannedURLProtocol setCannedHeaders:testHeaders];
[ILCannedURLProtocol setCannedResponseData:testData];

Make sure to unregister the ILCannedURLProtocol after each use:

[NSURLProtocol unregisterClass:[ILCannedURLProtocol class]];

See also:

ILProfilerCompat.c

This file provides a workaround for an error that sometimes occurs when enabling code coverage metrics on iOS using LLVM/Clang and libprofile_rt.dylib:

Detected an attempt to call a symbol in system libraries that is not present on the iPhone: fopen$UNIX2003 called from function llvm_gcda_start_file in image ...

To fix this problem simply include this file in your testing target build.


Feel free to add enhancements, bug fixes, etc. and provide them back to the community!

Thanks,

Claus Broch

About

Various helper classes to assist when testing for iOS and Mac OS X

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Objective-C 86.5%
  • C 12.3%
  • Ruby 1.2%