Summary
Throughout this chapter, we looked at how we can write test cases for different components of our web application project with Django. We learned about why testing plays a crucial role in the development of any web application and the different types of testing techniques that are employed in the industry to make sure the application code they ship is stable and bug-free.
We then looked at how we can use the TestCase
class provided by Django's test
module to implement our unit tests, which can be used to test the models as well as views. We also looked at how we can use Django's test
client to test our view functions that require or do not require the user to be authenticated. We also glanced over another approach of using RequestFactory
to test method views and class-based views.
We concluded the chapter by understanding the predefined classes provided by Django and where they should be used and looked at how we can modularize our testing codebase to make it...