Change the future

Thursday 9 a.m.–12:20 p.m.

Fully Test-Driven Web Development with Django and Selenium

Harry Percival

Audience level:


The concept: run through the official Django tutorial, but with full TDD.

So, Browser-based testing with Selenium + in-depth unit-testing;

TDD Discussions: what to test, what not to test;

Aimed at beginners (new to Django, TDD or Selenium)

Come prepared! you’ll need Git, Firefox, Python2.7, Django1.4 and Selenium installed


Fully Test-Driven Django with Selenium

AKA “The Django Pony vs The Testing Goat”

This tutorial is aimed primarily at people who want to learn about one or many of:

  • Django
  • Selenium
  • Test-Driven-Development

So it’s aimed at beginners of one kind or another – if you are already well versed in all three, then you may not get much out of it.

The idea is to run through the steps covered by the official Django tutorial, covering the essentials of Django from a beginner’s point of view. However, at each stage, instead of “just” writing the Django code required to build our site, we first write tests.

And we don’t just write unit tests! We start by writing “functional” or “acceptance” tests, using Selenium - which means driving a real browser, and checking the actual behaviour of the site as it is rendered, from the user’s point of view.

Why should you listen to me, I hear you ask?

Well, I was lucky enough to get my first “proper” software development job about two years ago with a bunch of Extreme Programming fanatics, who’ve thoroughly inculcated me into their cult of Test-Driven development. Believe me when I say I’m contrary enough to have questioned every single practice, challenged every single decision, moaned about every extra minute spent doing “pointless” tests instead of writing “proper” code. But I’ve come round to the idea now, and whenever I’ve had to go back to some of my old projects which don’t have tests, boy have I ever realised the wisdom of the approach. So, I’ve learnt from some really good people, and the learning process is still fresh in my mind, and most importantly, I still have the passion of a recent convert!


Come with the following pre-installed on your laptop please:

  • Git
  • Firefox
  • Python 2.7
  • setuptools/easy_install/pip then:
  • pip install django
  • pip install selenium
  • pip install mock

Here's a video of this workshop at EuroPython 2012

Update: See updated tutorial preparation instructions at Fully Test-Driven Web Development with Django and Selenium - Git, Firefox, Django, Selenium