Open Source iOS Library For Stubbing HTTP Requests With A Simple Syntax

A few weeks ago I mentioned I mentioned the OHHTTPStubs library for making stub network requests for testing networking features within your iOS apps.

That’s a great library, but if you’re looking for an easier to create stub network tests I’ve come across another library called Nocilla.

Nocilla provides  a very simple DSL for creating your stub requests.

Here’s an example of the syntax for creating an HTTP request complete with headers, body, and status code:

stubRequest(@"POST", @"https://api.example.com/dogs.json").
withHeaders(@{@"Accept": @"application/json", @"X-CUSTOM-HEADER": @"abcf2fbc6abgf"}).
withBody(@"{\"name\":\"foo\"}").
andReturn(201).
withHeaders(@{@"Content-Type": @"application/json"}).
withBody(@"{\"ok\":true}");

You can find Nocilla from Luis Solano on Github here.

The usage examples on the Github page use the Kiwi BDD testing library.

Another great library for testing networking features.

DeliciousTwitterFacebookRedditLinkedInEmail

Original article: Open Source iOS Library For Stubbing HTTP Requests With A Simple Syntax

©2012 iOS App Dev Libraries, Controls, Tutorials, Examples and Tools. All Rights Reserved.


Leave a Reply

Your email address will not be published. Required fields are marked *