Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Current »

Test the complete software

The backend system can a lot more easily create automated tests for every API, feature, service and run them automatically.

In Django projects, tests are in files starting with test in the app folder. For example, in the medical module:https://github.com/openimis/openimis-be-medical_py/tree/develop/medical there is mainly test_api.py This file in turn contains a list of methods also starting with test. They can be specified directly or within a TestCase class (the method still have to start with test)

By convention, test_services.py performs tests specific to the service interfaces of the module, testing mostly the business logic. test_api.py is more targeted at the GraphQL API. It should contain a few typical queries, a minimal, a maximal one, one without authentication at all, another with authentication but without the required rights to perform the operation, at least one test per mutation and whatever makes sense for that module. There can be additional test suites. The claim module for example includes a test_validations.py that tests every claim validation rule and combination thereof.

All these test suites are run automatically by GitHub actions on each push/pull request. The results of those test runs are available on each module in the Actions tab. That includes the tests for that module specifically. The openimis-be_py module does run all tests of all modules but it is not run when another module is updated, mostly when preparing a release.

Sample test run of medical items: https://github.com/openimis/openimis-be-medical_py/runs/3552714124?check_suite_focus=true

The run section reports:

 ..............
----------------------------------------------------------------------
Ran 14 tests in 3.586s

Medical items & services

This module doesn’t have actual business logic, so only API tests are performed:

https://github.com/openimis/openimis-be-medical_py/blob/develop/medical/tests_api.py

https://github.com/openimis/openimis-be-medical_py/runs/3552714124?check_suite_focus=true

 ..............
----------------------------------------------------------------------
Ran 14 tests in 3.586s

  • No labels