Introducing vREST NG CLI - A command line partner of vREST NG Application
Tags: testing, devops, vrestng, apitesting
Published: 2020-01-13 07:55:32

Hi friends!!! Today, I would like to introduce [vREST NG CLI](https://ng.vrest.io/docs/cli/) which is the command line partner of [vREST NG Application](https://ng.vrest.io). With vREST NG CLI, you will be able to execute your API tests on the command line as well. It uses the **same runner component** as used by the vREST NG Application itself. So, whatever works in the vREST NG UI Application will seamlessly work on the command line as well using vREST NG CLI without any further hassle. It also provides beautiful and usable reports to debug your API failures quickly.

Follow the instructions to download and install this utility from this [github link](https://github.com/Optimizory/vrest-ng-cli). vREST NG CLI provides the following two commands:

# 1. Run Command:
Run command will help you in the following tasks:

  1. You can execute your test cases on the command line. Provide the vREST NG project directory path to the `vrest-ng-cli` command to execute the tests. For detailed instructions, please follow our [guide link](https://ng.vrest.io/docs/cli/execute-test-cases.html).
  `$ vrest-ng-cli run --projectdir=<VREST_NG_PROJECT_DIR_PATH>`
  
  2. You can monitor your APIs health at specific intervals by linking this command with any third party schedular or cron utility.

  3. You can validate your application builds by integrating this command with any CI/CD servers like Jenkins, TeamCity, Azure DevOps, Gitlab CI, CircleCI, Bitbucket pipelines etc.

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/dc9e78e3gp13gqrhjolx.png)

Run command provides the following loggers to provide the detailed execution report:

  1. **Console Logger**: This is the default logger. This logger will output the test execution log on the console in a beautiful way. It will print the test summary, assertions results and diff report in case of test failure on the console.

    **Execution on the Command Line**: If you execute the tests on the command line then `vrest-ng-cli` provides the report in the following way:

    ![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/esuccuz0bsdsd9uimemz.png)

    And if you are executing the [data driven tests](https://github.com/Optimizory/examples-vrest-ng/tree/master/test/ddt-tests), then it will show you the test case summary, iteration number and iteration summary to easily debug your API failures.

    ![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/ffld2paj0fruyw7zsyxc.png)

    **Execution in Jenkins**: The same console report is also available in any CI/CD Servers like Jenkins server as shown below:

    ![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/s9wx4sk32b0rwtf9ztch.png)
  
  2. **XUnit Logger**: This XUnit logger will generate the xml report which can be used in any CI/CD servers like Jenkins to publish the report. The published reports using xunit logger provides the following two types of report:

    **a) Failed Test Cases List Report**

    ![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/navrp2ukup2x6qkfsjwt.png)
    
    **b) Individual Test Case Failure Report**

    ![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/pqt4vwe09mv4c31wqld0.png)

  3. **JSON Logger**: This logger will generate the report in JSON format which you may consume by any other tool/script.
    ![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/x1nj0ktkapiw992kfx99.png)

  4. **CSV Logger**: This logger will generate the report in CSV format. So that you can visualise the report with Microsoft Excel Sheet, Numbers etc.

    ![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/j4gse7yvvsmn9zk9haue.png)

# 2. Import Command
Import command will help you in achieving the following tasks:

  1. It is helpful in importing tests from various sources like vREST Cloud, Postman, Swagger.
  2. It can also be used in syncing your tests automatically whenever there is some change in swagger schema file.

So, in this way, you may use [vrest-ng-cli](https://ng.vrest.io/docs/cli/) utility to continuously validate your application or sync your test cases with swagger definitions changes.

This post is just an introduction to vREST NG CLI utility. I will post detailed step by step instructions on integrating this with CI/CD servers later on. If you like this post helpful then do like, comment and share with your friends and colleagues. You can connect with me on [LinkedIn](https://www.linkedin.com/in/aggarwaldheeraj/) and feel free to message me if you would like to discuss anything.