The Testing Goat

Obey the Testing Goat!

TDD for the Web, with Python, Selenium, Django, JavaScript and pals...

Test-Driven Development with Python, 2e, cover

The book

This is my book about Test-Driven-Development for web programming, published by the excellent O'Reilly Media.

There are a few ways you can read and support this book:

Obviously these are my favourite options! O'Reilly have been great, they deserve your support, and although I only get a small amount in royalties (about a dollar per sale if you're curious), it still pays for the occasional dinner out every month which I appreciate. Plus, real physical books are nice...

TIP: I don't recommend you use Google Play Books, or at least not their PDF version, it's horrible

Alternatively, or in the meantime, help yourself here! It's all free and CC-licenced (thanks O'Reilly!). I see this as a "try-before-you-buy" scheme, and I hope that if you enjoy it you'll buy a copy -- if not for yourself, then perhaps for a friend!

And do get in touch with comments, suggestions, corrections etc! [email protected]


Cosmic Python

Announcing a new book, "Architecture Patterns with Python", aka Cosmic Python

Wed 03 June 2020 by Harry

Python Architecture Stuff: do we need more?

What's been on my mind recently is "architecture stuff" -- kinda where I left off at the end of my book, how to structure your code to be able to get the most out of your tests, but more importantly, manage complexity over time. Would love to know what others are thinking about this...

Mon 11 February 2019 by Harry

A Pytest pattern: using "parametrize" to customise nested fixtures.

From time to time we come across a fixture that we want to customise in some way. Factory functions and factory fixtures are classic options, but you can also (mis-) use the pytest parametrize decorator to achieve this goal. Find out how here!

Fri 19 October 2018 by Harry

Second edition is out! Reviews please!

The second edition is now out in print and ebook, and just needs reviews! (and, you know, as a nice side-effect, sales)

Tue 12 September 2017 by Harry

Upgraded to Selenium 3! (and Geckodriver)

Well, that was bit of a slog! I've managed to get the book upgraded to the newer version of selenium, and it involved quite a lot of pain with explicit waits, and renumbering all the chapters, but I think the book is better for it. read on!

Sat 11 February 2017 by Harry

Second Edition update: Virtualenvs, Django 1.10, REST APIs, cleaner FTs...

Progress on the second edition is pretty good! I've got a first cut of some appendices on REST APIs, I've upgraded to Django 1.10, I'm recommending a virtulaenv all the way through, and I've improved the massive Chapter 6 rewrite slog by separating out FTs into one for regression and one for new stuff.

Tue 06 December 2016 by Harry

Plans for the second edition

I'm currently working on a 2nd edition for the book. Here's an outline of what I'm planning.

Sun 25 September 2016 by Harry

Page 1 / 4 »

Read the book

The book is available both for free and for money. It's all about TDD and Web programming. Read it here!

Reviews & Testimonials

"Hands down the best teaching book I've ever read""Even the first 4 chapters were worth the money""Oh my gosh! This book is outstanding""The testing goat is my new friend"Read more...


A selection of links and videos about TDD, not necessarily all mine, eg this tutorial at PyCon 2013, how to motivate coworkers to write unit tests, thoughts on Django's test tools, London-style TDD and more.

Old TDD / Django Tutorial

This is my old TDD tutorial, which follows along with the official Django tutorial, but with full TDD. It badly needs updating. Read the book instead!

Save the Testing Goat Campaign

The campaign page, preserved for history, which led to the glorious presence of the Testing Goat on the front of the book.