Alan Una Larisa - Writing tests for a Django application doesn't have to suck

Writing tests for a Django application doesn't have to be painful. Learn how to simplify and automate your testing with Django Mockingbird, a library that helps you mock Django queries and reduce test complexity.

Key takeaways
  • Writing tests for a Django application doesn’t have to suck.
  • The problem with current testing is that it often involves creating objects in the database and performing actions on them, which can be error-prone and time-consuming.
  • Mocking Django’s object relational mapper queries can make testing easier, faster, and more efficient.
  • The goal is to simplify testing and automate it as much as possible.
  • The library, Django Mockingbird, is designed to help with this by providing a way to mock Django queries and avoid creating objects in the database.
  • The benefits of using this library include:
    • Faster tests
    • Less error-prone
    • More independent and self-contained tests
  • Using Django Mockingbird can lead to:
    • More tests being written
    • Better quality of software
    • Improved developer experience
  • The library is designed to be easy to use and provides several ways to monkey patch the mock object.
  • The author of the library also encourages users to look for their own solutions and contribute to the library.
  • The Django community has a growing belief that unit tests should not touch the database, and using this library can help with this.
  • The library is designed to be flexible and can be used with other testing frameworks and libraries.