new all

Test driven development with Django

2011-11-17

I went to a workshop last night on TDD (Test Driven Development) using django and selenium, which was given by Harry Percival. It was hosted at skills matter exchange in London and there was free beer and pizza…which was an unexpected bonus!

There must have been around 35 attendees with a mixture of skill sets and backgrounds and it was an extremely good introduction not only to TDD but also to django framework, and almost everyone kept pace and I was impressed by Harry's enthusiasm for TDD and why you should be adopting it for development.

I also think it highlighted the accessibility of the django framework and how you can pick up on it very quickly, and half way through the pace was picked up as everyone in the room was generally flying though the work. The workshop was based on the django tutorial writing my first app which leads you through from starting a project to creating a polls application, which you can administer through the admin interface and is a gentle introduction to the models / templates / view paradigm adopted by django.

So you go from installing and setting up a basic django project and application to firing up selenium to check each step of your progress along the way.

The key thing that I took away from it was the develop - test - develop - test loop that you need to cycle through, in order to be really TDD, the tests direct all development, so the steps are small and incremental. Even though you know creating a models.py file with an model class that doesn't even extend from django.db.models.Model, you do just enough to pass the next step of the test. Which should end up with you not developing unnecessary code, which can happen when you are developing without tests and you try to cover all possibilities without thinking about what the application will actually deliver upon. You design your tests up front which you then write code to pass each step/test along the way. Write a test that fails, write the code to make it pass.

You can follow all this along simply by going to Harry's website, I recommended you do if you are interested in trying TDD and preferably with the django framework, this is really aimed at everyone and so no experience is necessary.

Well done to harry for delivering such a good introduction on TDD with django and selenium! There could be more workshops lined up, so if your in London and fancy coming along, check the python-uk mailing list to see when any future workshops are planned.

Simons blog / 2011 / 11 / 17

next: Favourite quotes

new all
github.com/simonhayward
twitter.com/simhay
Mastodon