# Executing Test Cases via command line

Run command of vrest-ng-cli binary is used for running the API test cases on the command line that are stored in a project directory.

# Usage Instructions

vrest-ng-cli run --projectdir="<path_to_tc_directory>" 
            [--testsuites="<comma_separated_test_suite_ids>"]
           [--tags="<comma_separated_tag_names>"]
           [--env=<environment_name>] [--nosslcheck=<boolean_value>]
           [--consoleLogging=<boolean_value>]
           [--logger=<one_of_available_loggers>] 
           [--logfilepath="<path_of_log_file_for_logger>"]
           [--record=<boolean_value>]
           [--token=<cli_token>]

# Example

vrest-ng-cli run --projectdir=/path/to/your/project/directory 
            --testsuites="Sample\ Test\ Suite"
            --logger=xunit 
            --logfilepath=/path/to/directory/for/vrest-logs/logs.xml

And if you would like to record the test execution results in the vREST NG Dashboard Service then

vrest-ng-cli run --projectdir=/path/to/your/project/directory 
            --testsuites="Sample\ Test\ Suite"
            --logger=xunit 
            --logfilepath=/path/to/directory/for/vrest-logs/logs.xml
            --record=true
            --token="paste the generated CLI Token here"

Note: For information on generating CLI Token, you may look at our guide on CLI Token.

# Options

    --projectdir     : Provide the path of the project directory which 
                       contains the testsuites.json file.
                       
                       If you don't provide any filter, then it will execute
                       all the test cases available in the project.

    --testsuites      : Optional Filter: Provide the comma-separated list of 
                        test suites which you want to execute in double-quotes.
    --tags            : Optional Filter: Provide the comma-separated list of 
                        tags that you want to execute in double quotes.
    --methods         : Optional Filter: Provide the comma-separated list of 
                        method names that you want to execute in double quotes.

    --exclude-testsuites: Optional exclude filter: Provide the comma separated
                        list of test suite ids which you don't want to execute
                        in double quotes.

    --exclude-tags    : Optional exclude filter: Provide the comma separated
                        list of tags which you don't want to execute in double
                        quotes.

    --exclude-methods : Optional exclude filter: Provide the comma separated
                        list of method names which you don't want to execute 
                        in double quotes.

    -T, --timeout     : How much to wait for a response after execution 
                        of the test case.
                       
                        It should be provided in units of seconds.
                        e.g. -T=3 will wait for 3 seconds for the response

    -N, --env         : Provide the environment name to initialize 
                        the global variables.
                       
                        By default environment `Default` is used.
    
    --envfilepath     : Provide the environment file path containing extra 
                        run time variables (key/value pairs) in JSON format.

    --vars, -v        : Provide extra run time variables through this option
                        apart from `--env` option.             [default: {}]
    
    --token           : Provide the authentication token to store the test 
                        run results on vREST NG Dashboard Service.

    --record          : If this argument is `true`, then the runner will
                        record and store the test run results in vREST NG
                        Dashboard Service.     [boolean] [default: false]
    
    --commitid        : Provide the version control commitId to associate with
                        the current test run in vREST NG Dashboard Service.

    -S, --nosslcheck  : If this argument is `true`, vREST NG CLI will process
                        all requests, without Secure Certificate Check.
                       
                        By default, Secure Certificate Check is enabled. 
                       
                        This option is useful in the self-signed certificate 
                        issues.
            
    -C, --consoleLogging: If this argument is `false`, then the runner will not
                        log the results on the console.

    -L, --logger      : Your desired logging of the vREST NG CLI execution 
                        process and result.

                        This can be either `console` or `json` or 
                        `csv`, `xunit`, or `custom`.

                        By default `console` logger is used.
    
    --logscriptpath: Valid if logger value is `custom`. Provide file path of
                        the logger script to generate custom formatted output.

    -F, --logfilepath : Valid if other than `console` logger 
                        is selected.

                        The absolute path of the log file, into which 
                        execution process and result logs will be dumped.

                        If path/file is not present, the tool will try 
                        to set up that path, and create a file automatically.

                        Please note that if the file already exists, 
                        that will be overwritten.

                        By default it will be the `vrest_logs/logs.[json|xml|csv]` 
                        in current directory.

    --stoponerror     : Specify -1 if you want to skip the current test suite on 
                        error. Specify 0 if you don't want to stop on error. 
                        Specify 1 if you want to stop on the first error. Otherwise, 
                        specify any number if you want to stop the execution after 
                        the specified number of failed executions.    [default: 0]

    --proxy           : If this argument is `true`, then the runner will respect the 
                        proxy-related environment variables HTTP_PROXY, HTTPS_PROXY. 
                        Otherwise it will not use the proxy settings. [boolean] [default: true]

    -H, --help        : To see this help.

Note:

  1. For more information on how you may write a custom logger to generate customized output, you may follow our guide on custom logger.
  2. For more information on providing run time variables through option --vars or --envfilepath, you may follow our guide on run time variables.

When you execute this command, then this will execute the tests and will show you the following report on the command line: