Contribute Media
A thank you to everyone who makes this possible: Read More

Intermediate testing with Django: Outside-in TDD and Mocking effectively

Description

Once developers have got the hang of the basics of testing, problems of applying it in the real world soon start to manifest themselves, and common questions come up.

  • What order should I write my tests and code in to avoid wasting time on blind alleys?
  • If I'm using Mocks in my tests to avoid external dependencies, how do I avoid getting stuck with unwieldy, unreadable tests that don't actually tell me when things have gone wrong?
  • Unit tests vs integration tests vs functional tests, which should I use when, and what are the trade-offs?

In this tutorial we'll work through an example of using an existing Django codebase, adding a new feature, and experimenting with different testing techniques along the way to illustrate the pros and cons of each

  • bottom-up vs outside-in development
  • double-loop TDD
  • using Mocks to isolate application layers from each other
  • "listen to your tests", and learning to use ugly or convoluted tests as a signal for improving design.

Some familiarity with Django is desirable, although skills learned in other web frameworks are transferrable. By the end, you'll be able to go back to your own projects with practical experience, and a new way of thinking about how to optimise your tests for your own circumstances.

Details

Improve this page