Skip to content

6. Tests

Alex Levshin edited this page Apr 27, 2017 · 7 revisions

Getting started

Currently, the project has on board about 300 functional and integration tests, implemented on the Mocha framework. Functional tests are placed in tests/functional, tests/integration folders and broken down into categories restapi and websocketapi, integration tests contain restapi. In these tests, you will find the main examples of scenarios how to interact with the platform APIs.

How to run

  • Prerequirements

Before you begin, read the Database section. If you have already installed the database, you can run the tests. Here is the list of utilities needed to get started:

To run the tests, you must first install the node libraries (should be installed npm utility) from the tests/functional or tests/integration folders:

npm install

After successfully installing the libraries, you can run the functional tests:

export ROOT_FOLDER=/opt/workty-mocha-tests/dev/x64/1.0.0
export MONGO_DB_NAME=workty
mocha --ui bdd --recursive /opt/workty-mocha-tests/dev/x64/1.0.0/functional/v1

For integration tests only the folder changed:

mocha --ui bdd --recursive /opt/workty-mocha-tests/dev/x64/1.0.0/integration/v1

If you need to integrate with CI systems like Teamcity, you can use the reporter script for mocha tests, which is located at Mocha teamcity reporter. Then the tests run line changes to the following:

mocha --ui bdd --reporter /opt/workty-mocha-tests/dev/x64/1.0.0/node_modules/mocha-teamcity-reporter/lib/teamcity.js --recursive /opt/workty-mocha-tests/dev/x64/1.0.0/functional/v1

Also I recommend using the script located on the tests/deployment/gulpfile.js path to create a zip archive with all the necessary files. The command to run the gulp script:

gulp --color --gulpfile ./tests/deployment/gulpfile.js --build_version=1.0.0 --arch=x64 --branch_type=dev --outputlocaldir=/opt/workty-mocha-tests

Let's look at the input parameters:

  • build_version The build number. Required. Default value 1.0.0
  • arch The architecture type of the processor, only the x64 value supports the script. Required. Default value x64
  • branch_type The name of the branch for the build type dev or prod. Required. Default value dev
  • outputlocaldir The name of the output folder for the zip archive. Required

After a successful build, you will find the zip archive along the path for the default values ​​/opt/workty-mocha-tests/dev/x64/1.0.0/workty-mocha-tests-dev-x64-1.0.0.zip.

Clone this wiki locally