Introducing Test Cases
Ghostwriter follows Django’s best practices and recommendations for unit testing. You can read more about Django unit tests here:Writing and running tests | Django documentation | Django
Running Tests & Examining Coverage
Tests are run through Django’s manage.py and thetest command. You can run all tests, a subset of tests, or individual tests. See below for examples:
Test Coverage
The above commands include the usage of Python’s coverage library. Coverage compares the executed tests against the codebase to identify lines of code that were not tested.Coverage.py — Coverage.py 5.5 documentation
docker-compose -f local.yml run django coverage report -m
A GitHub Action executes unit tests, generates an XML Coverage report, and uploads the report to CodeCov. This Action fires after commits to the master branch and whenever a PR is submitted to the repository. CodeCov tracks unit test coverage and makes it easier to view which folders, files, and individual lines of code need more unit testing.