DjangoCon Europe 2023

Turning test writing into a consistently brief and pleasant experience
05-30, 12:25–12:55 (Europe/London), Music Hall

Writing tests for our web apps can be painful, slow, and boring. In this talk we look at 10 tools and techniques to make writing django tests a consistently pleasant experience.


Video: https://youtu.be/2n2hpN88b-M

There's one thing I enjoy least about software development: Writing tests. I appreciate the tests I've written in the past, but I do not enjoy the process of creating new ones. How can we make test writing a pleasant, brief, and fun experience? This talk looks at over 10 tools and techniques to accomplish exactly that.

  • Engage the audience with some live poll questions:
    • How much time do you spend writing tests?
    • How much do you enjoy writing tests?
    • Have you spent time improving your own testing experience?
  • What existing software engineering research says about how much time we spend on tests
  • How we think about writing tests for our web applications:

    • What value do we get from tests, why do we write them at all?
    • How many tests should we write? What do we not want to test? How important is coverage?
    • What tests should we write? Unit tests, integration tests, Not too many, mostly integration
    • When does test driven development help us? When does it not?
  • Techniques for making test writing more brief and more pleasant:

    • Putting in some time to write testing abstractions to improve the testing experience of your colleagues and future you
    • Testing utilities for managing time: freezegun, time machine
    • Testing utilities for dealing with outbound http requests: httpretty, response, VCR
    • Testing utilities for managing with SQL queries
    • Property based testing and ghostwriting with hypothesis
    • Kolo to turn recorded requests into tests
    • Pytest and the best plugins for saving time
    • Browser based testing: Selenium, storybook, etc.
    • Generating tests with large language models – How useful is Chat GPT?
    • Further tools and techniques from user interviews with django developers (this research is ongoing)
      • I’m in the process of interviewing ~20 django developers about their experience with writing tests and the steps the’ve taken to improve their test setup. I plan to incorporate many of the learnings in this talk
  • Summary, Recap, Conclusion

Attendees will come away with practical tips for how to improve their own experience writing tests.

Wil is the founder of Simple Poll, one of the most popular apps for Slack, which he develops with his small remote team. Wil loves Django, so naturally Simple Poll was created as a Django app 6 years ago.

Over the past two years, he has been exploring how to improve his own Django development workflow with a side project called Kolo. Kolo is a Django middleware and VSCode extension that shows you everything your Django app is doing as it’s running, making it much faster to ramp up on unfamiliar code and understand whats happening.