Two Things I Missed Functional Testing with WebTest

Python Logo

Ian Bicking’s WebTest is a helpful module for running functional tests against a WSGI app. You may already be using it, it’s the suggested way to test Pyramid apps, TurboGears and Google App Engine, and (although I have no experience with this) you can use it with Django (apparently this is a good idea) and Flask. It’s not very complicated but in my haste to get things done I overlooked a couple of its nicest features.


Lightweight BDD for iOS and OS X

XcodeI took a look at GitHub’s Mantle framework for iOS and Cocoa last Fall and am using it in one of my side projects this Spring. While reading through the Mantle source I noticed some dependencies on the Specta testing and Expecta matcher framework, neither of which I was familiar with. I was planning to use the Kiwi framework to implement some BDD style tests for my project, but decided to give Specta and Expecta a shot instead. (more…)

Book Review: How Google Tests Software

how_google_tests_softwareThis past week I finished reading the very interesting book, How Google Tests Software. I first heard about this book from an IT-Conversations interview with one of its co-authors, James Whittaker. The interview provides a good overview of many of the key points made in the book, but I still found it worthwhile to read the book.

The book itself is not a how-to book, providing concrete steps on how to test software. Instead the focus is at a higher level with much of the book devoted to describing the different testing roles within the company. There were three particular themes that jumped out at me from both the interview and the book itself.


Cocoapods for Testing HTTP Interactions

Cocoapods logo

When writing code to access resources over HTTP or another protocol it’s great to write some tests to make sure that code is working well, but running them can be a pain when working over a slow connection, with large requests, or when working offline.

Two great open source frameworks available as Cocoapods that make testing HTTP and other NSURLConnection based interactions easier are Nocilla and NSURLConnectionVCR. Interestingly, both projects were inspired by similar testing frameworks for Ruby. Nocilla draws from WebMock and NSURLConnectionVCR from the VCR project.

Nocilla provides a DSL for stubbing HTTP requests and works with the popular AFNetworking and MKNetworkKit frameworks too. An even nicer feature is that it won’t let requests without stubs hit the network and instead will return a 500 error and fail your test.

The NSURLConnectionVCR project takes a different approach and allows you to record the responses of NSURLConnection based requests to a file and then "replay" those results when your tests are run again. Using this approach with a number of recording files should let you test your code against a variety of responses very quickly.

It’s always nice to have some extra testing tools at your disposal and with Cocoapods making them so easy to include in your next OS X or iOS project there’s no excuse not to give them a try!