How to use Datastore Examples as a Scenario Outline data source

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, CSV, SQL, MOCA, and Datastore sources provide more dynamic permutations and less maintenance.

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

What are Datastore Examples?

Datastore Examples is the keyword used in Scenario Outlines to use tables in the Datastore as test parameters to be used in execution. The Datastore can be a local H2 database file, external Oracle, SQL Server, MySQL. The schema includes 8 tables and is integrated with the Datastore reporting DDL. The tables and expected data will be described in detail later in the article.

Why use Datastore Examples?

Datastore Examples for test parameter management provides a highly organized and flexible mechanism for executing scenarios.

How to use Datastore Examples?

Datasets are used with the keyword Scenario Outline: and declared on the line immediately following Scenario Outline.

Scenario Outline: Validate Tryon Home Page Text Elements
Datastore Examples:webElementDataset

In this example, the value webElementDataset refers to the name  column in the test_data_set table of the schema.

As of Cycle version 2.7.0 the Example Set Viewer allows for the management of data store examples inside of Cycle!

A visual representation of the schema is below:

image__4_.png

The schema is included with your Cycle installation using the Data Store Connection section of the Report Settings. This is an example of an H2 set up but any valid DB connection will work. Once connection has been confirmed using the Create/Update Database Tables will populate your defined Data Store with the table described in this article

mceclip0.png

The tables, their representation and how they relate to each other

test_plan = A group of data sets that are to be used together. The the test_plan.is_default flag must = 1 in order for the dataset to execute.


test_data_set = Header for the complete set of parameters and iterations for the Scenario Outline. The name column in this table is what is used in the Dataset: declaration in the Cycle Feature. The test_data_set table links to the test_plan table through test_plan_id.


test_data_record = Header table for the number iterations of the Scenario Outline. The test_data_record table links to the test_data_set table through test_data_set_id. For example if a Scenario Outline needs to execute 5 times there will be 5 entries in the test_data_record table all with the same test_data_set_id. The sort_sequence column will determine the order in which they execute.

test_data_tag = Header table for specifying iterations through tags. The test_data_tag table links to the test_data_record_tag table through test_data_tag_id.

test_data_record_tag = Table for assigning execution tags to iteration records. If a tag is specified at execution the the record must have that tag in order to be returned in the Examples query. This table links to test_data_tag through the test_data_tag_id. This table also links to test_data_record through the test_data_record_id.

test_data_column = Named columns to be used as chevron variables in the Scenario Outline. The test_data_column table links to the test_data_set table and the test_data_column table through test_data_set_id. 


test_data_value = Values for the columns in test_data_column to be used in variable replacement in Cycle steps. This table links to test_data_column through the test_data_column_id. This table links to test_data_record through the test_data_record_id.

data_type_lookup = Lookup table for variable data types; 1= STRING, 2 = INT, 3 = FLOAT. This table links to test_data_column through the id field.

At runtime, Cycle executes an integrated query to pull the iterations for the Scenario Outline. 

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

For instructions on populating values for the Datastore schema read this article.

Putting it all together

In this example, the Steps are designed to validate whether the text in the element on the web page matches the expected value. The goal is to execute this for all the data rows in our Examples organized by sort_sequence. Rows with the same sort_sequence represent a single iteration. This particular example checks 4 different element text values on the Tryon Home Page.

Query results (in table form for readability):

 mceclip0.png

The Scenario Outline:

Scenario Outline: Validate Tryon Home Page Text Elements
Datastore Examples:webElementDataset
Given I open <browser> web browser
Then I navigate to <site> in web browser
Then I maximize web browser
Then I see <value> matches all text in element <element> in web browser within 5 seconds
Then I close web browser

Only the values in the NAME results and the DATA_VALUE results are used in the Scenario Outlines.

The values in the NAME results map to the chevron <> variable name. In this example <browser>, <site>, <value>, and <element>.

The values in the DATA_VALUE results are what Cycle will use in each iteration of the Outline. In this example the first iteration would replace chevrons and execute:

Given I open "Chrome" web browser
Then I navigate to "https://www.tryonsolutions.com" in web browser
Then I maximize web browser
Then I see "(888) 256-2177" matches all text in element "id:et-info-phone" in web browser within 5 seconds
Then I close web browser

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

 mceclip0.png

    • Related Articles

    • 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, ...
    • Can I use Cycle's Data Store reporting even if I don't have a database available?

      Problem In-depth reporting and analysis of Cycle tests often requires the use of a database to log all of the details of your Cycle executions, but not all users have a readily available database to use for this. Solution Cycle comes pre-packaged ...
    • 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, ...