For the Orange Country Lettings project, my testing approach was comprehensive and aimed at ensuring the project’s functionality met high standards. The objective was to reach a minimum test coverage of 80%, but I exceeded this with a final coverage rate of 93%. To achieve this, I wrote tests covering each application’s models, views, and URLs, which were essential components for the project’s functionality.
Test Structure
In each tests.py
file, I created a ModelTestCase
class that inherits from Django’s TestCase
. This class served as a base setup for the data needed to run tests efficiently within each file. The setUpTestData
method populated essential data, ensuring that each test case had consistent data to validate different scenarios.
Model Tests
Each model had a corresponding test class where I verified:
View Tests
In testing views, I focused on ensuring that the views returned the correct HTTP status codes and displayed content as expected.
Choice of ModelTestCase
for Reusability
The ModelTestCase
class provided a reusable way to set up data that other tests could access. By using @classmethod
and setUpTestData
, I ensured that the data was created only once for the entire test class, improving test efficiency.
Coverage and Test Type Balance
To meet the high coverage requirement, I carefully tested:
With these practices, I ensured that the Orange Country Lettings project was thoroughly tested, covering key features and interactions in a structured and efficient way, achieving over 90% coverage.