Repository for DHIS2 API Testing.
- Cucumber: Framework for test automation using Behaviour Driven Development
- Axios: Promise based HTTP client for Node.js used to execute HTTP requests to DHIS2 REST API
- Chaijs: BDD/TDD assertion library
- Cucumber-html-report: Library used to generate HTML report after all test cases are executed
- Docker: Used to bootstrap a clean environment which executes all case tests using an isolated web application for the REST API and a custom database
- Create a Gherkin file inside
features
folder. A new folder should be created for each individual module (e.g./features/organisation_units
for organisation unit related test cases) - Create a JavaScript file inside
step_definitions
folder to execute the steps defined on the previous point. Check Cucumber.js documentation for more details
Set the environment variable DHIS2_GENERATE_HTML_REPORT
to true
if you want an html report to be generated. Default value is 'false':
$ export DHIS2_GENERATE_HTML_REPORT=true
Define the environment variable DHIS2_FEATURE
to only execute a specific feature file. If not defined it will execute all feature files:
$ export DHIS2_FEATURE=features/users/users.feature
Set the environment DHIS2_LOG_MODE
to debug
to log debug messages. If not defined debug messages will not be printed:
$ export DHIS2_LOG_MODE=debug
Set the environment DHIS2_API_VERSION
to desired api version to be tested. Default value is 27
:
$ export DHIS2_API_VERSION=27
Start tests execution:
$ ./run.sh # or run.bat for Windows
A local execution should not be used since it will not guarantee an expected state of DHIS2 Web Application for the tests. However, you might use it following these directions:
Make sure you have the required NPM dependencies installed:
$ npm install
Set the environment DHIS2_BASE_URL
to desired DHIS2 Web endpoint. If not defined it will use default endpoint as https://play.dhis2.org/demo
:
$ export DHIS2_BASE_URL=https://play.dhis2.org/demo
Run tests:
$ npm test
All environment variables mentioned before might be used.