Testing

This page describes our code testing.

We maintain a high code coverage percentage with unit and integration tests for every function, serializer, and management command. We are using a package called Coverage (https://coverage.readthedocs.io/en/v4.5.x/) to track code coverage.

To run unit tests without using Coverage:

$ python manage.py test

To run unit tests using Coverage with comprehensive code coverage report generated into an HTML file:

coverage run manage.py test && coverage combine && coverage html

This command will generate a directory that is ignored by Git via our .gitignore file. To see the code coverage open the file /coverage_html/index.html in a browser.

Coverage options are specified in a configuration file called .coveragerc. This is where you would add files/directories you want to omit from our Coverage report.

'coverage combine' will take the coverage files created for multipricesses (located in the base directory) and will combine them with the main coverage files . If a test using multiprocessing fails these coverage files will remain and must be deleted manually.

We also tried to split unit and integration tests up between core PresQT code and Target code. Tests that cover core code reside in presqt/api_v1/tests/ while target tests that cover target functions reside in presqt/targets/{target_name}/tests/ .

Last updated