Django TestMaker

Posted in Testing, Frameworks, Development on December 19, 2008

At work lately we've been writing a bunch of tests for all of the work we've been doing. This is generally a good thing (tm). I was getting tired of manually having to write all of the code to test the views inside of my app. So I decide to write a little app that helps me automate the writing of tests.

I wrote a piece of middleware (that should obviously only be used during development!) that shadows the current activity in django into a log file. This log file should then be ready to copy and paste into a doctest for easy testing of your views. This is a little hard to explain, but the code should be pretty self explanitory.

I created a google code project for it so that people can go ahead and hack on it and make it better. It is pretty rudimentary at current, but it gets the job done.

I think a big win from this approach is that your testing data is much more "real", since it's a copy of your session with a real browser. I know writing django tests I sometimes use contrived data because it is a pain to enter it all. This should help improve on that situation.

Here is a video of it in action, this should allow it to make more sense.

Watch Video Watch Video on External Site

Tags: Testing, Frameworks, Python, Django