A practical guide to making your Django project’s tests faster. It has many tips and tricks that apply to all projects, big and small. And it covers the two most popular test runners: Django’s test framework and pytest.
Reducing test run time is the easiest and safest way to increase your speed of delivery. And it’s an organic way of increasing team happiness!
The content is based on my 8 years of experience with tests on Django projects. I’ve sped up many projects’ test suites, improved Django’s own testing framework, and created several pytest plugins.
I couldn't have picked up the book at anytime better. I was working on a large semi-multitenant Django codebase with almost zero test coverage. So, to capitalize on the advantages of having a greenfield project of significant size—I wrote a whole bunch of tests and started live-applying the bits of tips on them as I worked my way through the book. I started seeing immediate returns as the tricks began doing their magic.
What makes grokking the book fun is—it doesn't beat around the bush and dives straight to the point. I effortlessly finished the entire book in two sittings. However, it does assume some previous experience in writing tests using Unittest, Django's default test framework, and Pytest. The book starts with the easiest steps that you can take to speed up your test suite and then builds up from there. The fourth chapter where the author lays out an assortment of techniques that don't need much work is pure gold. Definitely worth your time if you want to familiarize yourself with a few effective strategies to optimize your Django test runs that aren't so readily available in the Django docs.
One thing about Adam's writing (also check out his blog) that most tech writings lack - clarity and succinctness. With this Adam trademark, this book unsurprisingly exceeded my expectations as well - "How is is possible?" You ask. A few reasons:
- You will get to peek into the toolbox of a Django core developer - You will learn the ins and outs of Django testing (unittest and pytest) - Your tests are going to be so much faster and much more accurate - You also get to learn the little tricks like `git log -S` that are scattered in the book/links to blog. These are small tricks, but these are tricks of superman.