Skip to content

Latest commit

 

History

522 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Integration tests

Prepare running environment

Integration tests require mocha framework.

  • Install mocha globally: $ sudo npm install -g mocha, Windows: > npm install -g mocha

  • cd to project root directory: $ cd devicehive-tests

  • Install Node.js references: Linux: $ sudo npm i, Windows: > npm i

  • When running specify tests directory 'integration-tests': $ mocha integration-tests

  • More advanced example of running tests with JSON reporter: $ mocha -R json integration-tests/rest-access-key.js > result.json

You can pick any of alternative reporters available in Mocha framework or third-party reporter, like mochawesome.

  • Install mochawesome globally: $ sudo npm install -g mochawesome, Windows: $ npm install -g mochawesome

  • Run tests: $ mocha -R mochawesome integration-tests. In order to set ip and port use: $ mocha -R mochawesome integration-tests --ip=${ip} --port=${port}. Default values: ${ip} = 127.0.0.1 ${port} = 8080**

Another easy way to run tests is to use WebStorm

When running tests in WebStorm you can export test results to .html file:

export_tests.png

Environment configuration

  • All tests use JWT tokens to procceed/fail with authentication process. To make hardcoded JWT tokens work you need to run them on DeviceHive server with JWT_SECRET=devicehive (default value). To configure your DeviceHive installation run following from your terminal:

$ export JWT_SECRET=devicehive

and only after this run

$ mvn clean package -DskipTests

from your DeviceHive java server home folder.

Tests structure

  • describe() closure defines a group of tests
  • it() defines a single test

tests_structure.png

Dealing with failures

  • Use only() predecate to run separate test or separate group of tests. This can be helpful to run the failed test only:

only2.png

Following code will only execute '#Group of Tests' group:

only1.png

  • To ignore test use skip() predicate:

skip.png

About

No description, website, or topics provided.

Resources

Stars

3 stars

Watchers

28 watching

Forks

Releases

Packages

Contributors

Languages