How to use MOCA Examples as a Scenario Outline data source

How to use MOCA Examples as a Scenario Outline data source

With the enhancements to Scenario Outlines, it is now possible to use multiple sources for test parameter data. Previously, parameters were set in the Feature in an Examples section specified and maintained by the user. The addition of Example Row, CSV, SQL, MOCA, and Datastore sources provide more dynamic permutations and less maintenance.

This article details what the MOCA data source is, as well as why and how to use it.

What is MOCA?

MOCA is a proprietary language for interaction with JDA WMS databases. MSQL files are the mechanism for MOCA execution in Cycle's Scenario Outlines. MSQL stands for MOCA Structured Query Language. MOCA Examples is the keyword used in Scenario Outlines to use a MSQL command result sets as test parameters to be used in execution. The command is contained in a .msql file. The MSQL command will return column names and those names will become the Cycle variable names. Each row in the result set will generate an iteration of the Scenario Outline.

Example:

Scenario Outline: MOCA Test
MOCA Examples:scripts\wh.msql connected to <MOCA_CONNECTION> logged in as <MOCA_CREDENTIALS>

Why use MOCA/MSQL?

When executing against a JDA WMS instance, using MSQL for Scenario Outline provides a dynamic way to build test parameter iterations. All MOCA commands, including custom created, can be used to return the parameters necessary to execute the test. Cycle returns MOCA status codes so instant feedback is delivered for troubleshooting. Static data values are not required. Once the command is built that generates the necessary parameters to use in the test it can be reused over and over. The data elements themselves may change but the command remains the same and therefore requires little, if any,  maintenance.

How to use MOCA Examples?

First and foremost you will need to have valid MSQL syntax in your .msql file. This is no different than executing Local Syntax or MOCA commands in your MOCA editor of choice.

MOCA Examples are used with the keyword Scenario Outline:. As in the previous example illustrates, it is declared on the line immediately following Scenario Outline.

Another critical piece to using MOCA Examples in Scenario Outlines is that you must provide Connection and Credentials for access to your WMS instance.

Before going any further please review the KB article on setting up Connections and Credentials in Cycle.

Once you have your Connections and Credentials saved, they are referenced with the following syntax immediately following the file path.

Example:

Scenario Outline: MOCA Test
MOCA Examples:scripts\wh.msql connected to <MOCA_CONNECTION> logged in as <MOCA_CREDENTIALS>

If you reference saved connections or credentials by an incorrect name or that have not yet been created you will receive the following error at execution.

mceclip2.png

If your connection string is invalid you will receive an error similar to below at execution.

mceclip3.png

If your credentials are invalid you will receive an error similar to below at execution.

mceclip4.png

The MOCA Examples keyword requires a file path relative to your Project directory with a valid MSQL file. In the example above we provided scripts\wh.msql as the path. The full path would be similar to C:\Cycle\PROJECT_DIR\scripts\wh.msql with PROJECT_DIR being the example Project directory.

When the Scenario Outline is executed, Cycle converts the column names from the result set to variable names as chevron variables and the subsequent data rows as the values to use in the Steps. Each data row will be an iteration of the Scenario Outline executions steps.

If there are no rows and that exception is caught then the Scenario Outline is skipped. This may be an acceptable procedure for your test. If your test should not proceed if no rows are returned then do not catch the exception.

For example if you have an MSQL file formatted like:

/* In my WMS instance this command will return 2 rows*/
list warehouses
|
publish data
where wh_id = @wh_id

/*Result set*/
mceclip5.png

then Steps use the chevron and variable replacement to use the information provided.

Given I echo <wh_id>

When the Step executes <wh_id> will be replaced with WMD1 in the first iteration and WMD2 in the second.

Putting it all together

In this example, the Steps verify successful connection for a specific terminal device. The MSQL file contains a command to return the list of terminal devices to validate.

MSQL file example:

list rf terminals
where wh_id = 'WMD1'
and term_typ = 'handheld'
and rf_ven_nam = 'LXE'

Scenario Outline example:

Scenario Outline:LXE Terminal Test
MOCA Examples:Datasets\lxe_terminals.msql connected to WMSTST logged in as WMSTST
Then I open terminal connected to"HOST:PORT" for terminal <term_id>
If I see "Terminal ID" on line 1 in terminal within 5 seconds
Then I enter <term_id> in terminal
Endif
Once I see "User ID" in terminal
Then I close terminal

When new terminals are added to the system that have the same criteria they will automatically get validated at Scenario Outline execution with no change to the MSQL file or the Feature.

The Output in the Output Panel shows each Example numbered individually for troubleshooting.

mceclip0.png

    • Related Articles

    • How to use Datastore Examples as a Scenario Outline data source

      With the enhancements to Scenario Outlines, it is now possible to use multiple sources for test parameter data. Previously, parameters were set in the Feature in an Examples section specified and maintained by the user. The addition of Example Row, ...
    • How to use a CSV file as a Scenario Outline data source

      With the enhancements to Scenario Outlines, it is now possible to use multiple sources for test parameter data. Previously, parameters were set in the Feature in an Examples section specified and maintained by the user. The addition of Example Row, ...
    • How to use a SQL query as a Scenario Outline data source

      With the enhancements to Scenario Outlines, it is now possible to use multiple sources for test parameter data. Previously, parameters were set in the Feature in an Examples section specified and maintained by the user. The addition of Example Row, ...
    • How to use Example Row as a Scenario Outline data source

      With the enhancements to Scenario Outlines, it is now possible to use multiple sources for test parameter data. Previously, parameters were set in the Feature in an Examples section specified and maintained by the user. The addition of Example Row, ...
    • What improvements to Scenario Outlines should I be aware of?

      What do we know about Scenario Outlines? Scenario Outlines are similar to regular Scenarios except that a Scenario Outline executes multiple times, once for each row of data it is using. What is staying the same? The keyword Scenario Outline: The ...