March 17, 2013
Record and playback HTTP interactions with HAVCR

Inspired by VCR library of Ruby, I created my first useful tool in Haskell. Introducing HAVCR, or “Haskell VCR” — a tool for testing your web API consumers written in Haskell.

HAVCR is built upon pipes library in order to provide a “proxy” between your application and the targeted web site. When an HTTP request is sent by your application and a subsequent response is received, HAVCR proxy records this interaction as a “cassette” and stores in a .yml file. When later your application performs the same request, it is not sent to the remote server, but is “played back” using the previously recorded interaction. This greatly speeds up your tests and permits them to run in absence of internet connection. You can also tweak the cassettes manually to test your application providing the cases that would be difficult to recreate or record otherwise.

HAVCR is very basic and crude, but it works. At least as a proof-of-concept. This is my first Haskell program, after all. I’m going to improve it. Once it attains a better shape, I’ll upload it to Hackage.

Meanwhile, your feedback is welcome! Feel free to create github issues with suggestions.

12:11am  |   URL:
Filed under: Haskell HAVCR testing