Scheduling on Linux/Mac

This post will explain, how you may schedule test cases written in vREST NG Application on Linux / Mac.

Prerequisite

Prerequisite for the machine, on which you want to schedule test cases.

Let's take a sample application (Contacts Application) and step by step guide on how we can schedule vREST NG test cases.

Note: You can find the source code of sample application at Github.

Step by Step Guide:

Step 1: Write your automated test suite in vREST NG Application

First you need to write test cases for your test application in vREST NG Application to ensure the build quality of your web application. You can find the test cases for our sample application in the Github repository here.

Step 2: Learn how vrest-ng-cli command works and get your hands dirty on it by installing it locally first

First try out the vrest-ng-cli module by following the guide Execute Test Cases using vREST NG CLI.

Once you setup this module on your local machine, you can execute the vREST NG test cases by executing the following command:

/path/to/vrest-ng-cli run --projectdir=<path_to_project_dir> --logger=xunit [--logfilepath=<absolute log file path>] [--env=<ENVIRONMENT>]

Step 3: Add the above vrest-ng-cli command in any external scheduler

Now, you can add this vrest-ng-cli command in any external scheduler like cron. That's it.

For example, if you want to schedule vREST NG test cases daily at midnight, then you may write the cron job like this:

0 0 * * * /path/to/vrest-ng-cli run --projectdir=/path/to/project/dir --logger=xunit --logfilepath=/path/to/xunit_report.xml --env=ENVIRONMENT_NAME >> /path/to/execution.log 2>&1

Example

Now let's try to schedule the tests of our sample application using crontab utility available in the Mac/Linux.

  1. Open the crontab editor with the following command
cronttab -e
  1. Add the following command in the opened editor
0 0 * * * /path/to/vrest-ng-cli run --projectdir=/path/to/examples-vrest-ng/test/ddt-tests --logger=xunit --logfilepath=/path/to/examples-vrest-ng/test/ddt-tests/xunit_report.xml --env=default >> /path/to/examples-vrest-ng/test/ddt-tests/execution.log 2>&1

If there are any errors while executing the command then those errors can be identified using the execution.log file.

The above command will schedule the tests daily at mid night. If you would like to schedule it at 1 minute interval for testing purposes then provide the following command:

*/1 * * * * /path/to/vrest-ng-cli run --projectdir=/path/to/examples-vrest-ng/test/ddt-tests --logger=xunit --logfilepath=/path/to/examples-vrest-ng/test/ddt-tests/xunit_report.xml --env=default >> /path/to/examples-vrest-ng/test/ddt-tests/execution.log 2>&1
  1. You may check the list of active cron jobs using the following command:
crontab -l