Skip to content

joaoantunes87/api-tests

Repository files navigation

Build Status

DHIS2 API Testing

Repository for DHIS2 API Testing.

Technology stack

  • 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

How to add new tests

  1. 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)
  2. Create a JavaScript file inside step_definitions folder to execute the steps defined on the previous point. Check Cucumber.js documentation for more details

Tests Execution

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

Local Execution

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.

About

Web API tests for DHIS 2

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published