Get Updates By E-mail 

Article Written By:
Johann Dowa

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.


  •  
  •  
  •  
  •  
  •  

Submit A Resource

Have you created a useful tutorial, library or tool for iOS development that you would like to get in front of our 300,000+ monthly page views from iOS developers?

You can submit the url here.

The resources we feel will appeal to our readers the most will be posted on the front page.

Comments