Orange Country Lettings Journal

Testing the project


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:

    • Successful creation of model instances.
    • Validation failures when creating instances with incorrect data.
    • String representations (i.e., the str method).
    • Deletion functionality to confirm the object is removed from the database.

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:

    • Model logic and constraints, to verify database interactions.
    • View rendering and status codes, to confirm the proper operation of pages.
    • URL routing, ensuring correct page responses.

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.


Designed by BootstrapMade and modified by DoriDoro