Automating Web Services

Here at Mozilla QA, we (obviously) do a lot of testing.  We have a test case management system called Litmus, which serves pretty well to keep track of all the tests we want to cover on a given release cycle.  But it’s aging and we have some improvements that we feel would be better done starting from the ground up with a new tool.  So, we are going to build a fresh-new test case management system that will (if all goes well) meet our needs much better.

The first thing to hit us will be the web-based back-end created by uTest.  These will be a collection of REST APIs that our web developers will write the UI to.  Part of my job is to write some tests against these APIs to make sure they do what they claim.

So I’m venturing forth into the HTTP API testing frontier.  Well… ok… it’s not really a frontier.  This is a pretty well-established country, actually.  There are lots of tools out there.  Several languages to choose from and several design patterns available.  So I’m starting my journey to pick what feels like it will work best for us.

Yet, we don’t actually have the implementation of the REST APIs.  We have the spec from the development team, though.  So my first act was to write some kind of Mock objects that would serve those APIs, against which I can write some automated tests.  When we get the real back-end, I will point my tests at the new server and it will work perfectly.  Right?

For the mock server, I chose to write a few servlets.  This was something I’d done before, so it seemed an easy way to start.  So far I haven’t implemented all the APIs, just a few to get me started.

Next, I wanted to try out a few of the testing frameworks out there.  One obvious choice to try (seeing as I already know Java) was the use JUnit and HttpUnit.  Works great, and easy to execute in Eclipse.  But to get some other flavor, I also implemented the same simple tests in Python with PyUnit.  Both were really simple to implement.  The hardest part (though not even really hard, only relatively) was parsing the XML.  Since I’ve used DOMs before, I started with minidom in Python and Xerxes in Java.  Yeah, old-school, I know.  I may choose a different XML parser in the future.

But the next thing I want to try is using a Behavioral Driven Development framework.  Of course, JBehave is there for Java and RSpec and Cucumber are the Ruby favorites. But does anybody have favorites in JavaScript or Python?  I’ve heard of Leaves for Python, Node and Jasmine for JavaScript.  What’s the favorite out there?

Leave a comment