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:
- 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.
- describe() closure defines a group of tests
- it() defines a single test
- Use only() predecate to run separate test or separate group of tests. This can be helpful to run the failed test only:
Following code will only execute '#Group of Tests' group:
- To ignore test use skip() predicate: