Cycle 2.5 introduces enhanced Scenario Outline functionality. This enhanced Scenario Outline functionality gives the ability to manage test data across multiple permutations.
An Overview of enhanced Scenario Outlines can be found here.
The Cycle Datastore is one of several available sources for managing Scenario Outline test parameters. The data is created and maintained within the Cycle Datastore.
The Scenario Outline utilizes the Datastore through the use of the Datastore Examples key word. More information regarding the Datastore can be found here.
The purpose of this article is to describe several methods you can use to populate the Datastore with data for your Scenario Outline. The methods described in this article are not the only options for populating the Datastore. Many factors can influence the decision on how to maintain your Datastore. Datastore DB type, available tools, organizational requirements, long term maintenance, and ease of use are some examples of factors that need to be considered when determining how your Datastore will be managed.
Access to the Datastore Database
You will need access to the Datastore database in order to create and maintain test parameter data.
To set up your Datastore conection within Cycle, go to Project Settings > Datastore Settings.
For this article, I will be using a database management tool called DBeaver. DBeaver is a free, multi-platform database manager that includes drivers for the supported Cycle Datastore database types (DB2, Oracle, SQL Server, H2). DBeaver includes the ability to execute SQL statements against the database and also allows for inline editing of database records.
You can find more information and a link to download DBeaver here.
Maintenance with Inline Editing
Inline editing provides the quickest and most interactive method for maintaining Datastore data. You can easily add, delete, and copy rows in the Datastore table. Rows can be modified by typing directly in the data field or by opening an editor window.
Displaying Table Data
You must display the table data in order to take advantage of inline editing. There are several options for opening a table and displaying its data.
You can display table data by right clicking the table name in the Database Navigator panel and then selecting Edit Table in the context menu.
Alternatively, you can double click the table name in the Database Navigator panel and then click the Data tab to view the table contents for reviewing or editing.
The Data grid displays all of the current data within the table (similar to what a 'SELECT *' SQL query would return) and includes several different controls for manipulating the data that we will explore in the next sections.
We will be maintaining data in the Datastore TEST_DATA_VALUE table as an example for this article.
Adding a Row
Create a New Row
Create a new row by click the green plus sign available in the controls at the bottom of the Data grid.
Clicking the 'Add new row' button will insert a new row into the data grid. If there is currently no data in the table, the new row will be the first row in the data grid. If data already exists, a new row will be inserted after the currently selected row.
The new row is inserted into the data grid with NULL values in all fields.
Populate Row Data
Double click the field you want to edit to open an editable text field.
Enter the value into the text box and press Tab to move to the next column. This action records the entered value in the field and then makes the next field in the row editable.
Adding Valid Foreign Keys
Some table fields within the Datastore are foreign keys from other tables. For example, when adding a row in the TEST_DATA_VALUE table, you must ensure the TEST_DATA_RECORD_ID is a valid value in the TEST_DATA_RECORD table.
Database integrity is enforced within the Datastore. An invalid foreign key will prevent the row from being committed when you attempt to save it. DBeaver includes a tool for selecting a foreign key value from the related table.
With the data field selected, click the 'Panels' button on the right side of the data grid.
This opens a new panel named 'Value' to the right of the data grid. This panel displays the valid possibilities for the currently selected field based on the foreign key values defined in the related table.
Click on the value you want to add to your new row, and the value will populate the data field.
Save the New Record
Continue populating the data fields until all of the required data is entered and you are ready to save your row to the database. DBeaver includes a change indicator (*) next to the table name on the table tab as well as a highlighted green row to indicate the new row is not committed to the database.
Save your changes to the database by clicking the 'Save' button on the bottom of the data grid.
The change indicator and green highlighting are removed once the new row is saved to the database.
You can cancel your edit and discard changes by clicking the 'Cancel' button on the bottom of the data grid. This will revert the table to its previous state.
Deleting a Row
Select the row you want to delete from the database table by clicking a field on the desired row.
Click the 'Delete' button below the data grid.
The row selected for deletion is highlighted and the table tab is marked with the change indicator to identify there are uncommitted changes. DBeaver supports Ctrl+Click and Shift+Click to select multiple cells at a time.
Click the 'Save' button to complete the row deletion once all required rows are selected.
The selected rows are removed from the database.
Click the 'Cancel' button to cancel the delete action before saving and retain the row in the database.
Copying Rows
Creating new rows by copying existing rows and modifying key values can save time and effort when populating the Datastore. DBeaver provides functionality for copying existing rows.
Begin by selecting the row(s) that you want to copy. DBeaver supports Ctrl+Click and Shift+Click to select multiple rows.
Click the 'Duplicate current row' button on the control row at the bottom of the data grid.
This inserts new rows (highlighted green) below the selected records in the data grid. Note that the new rows include duplicated data from the originally selected rows.
Modify the rows with appropriate data while keeping in mind any primary and foreign key constraints.
Click the 'Save' button to save the rows to the database.
The copied rows are saved to the database with the updated values.
Click the 'Cancel' button to remove the duplicated rows before saving and revert to the previous state.
Modifying a Field
Individual fields can be modified using inline editing. You can modify a field's value directly in the data grid or by using an editor window.
Modifying Data Using the Data Grid
Double click the field you want to modify within the data grid. The field will become an editable text box.
Enter the new field value and press Enter, or you can press Tab to move to the next editable field on the row. Note that clicking another cell or pressing tab shows that the edited field is highlighted. This indicates the field value has changed, but it is not committed to the database.
Press the 'Save' button to save the edited row to the database.
The updated row is saved to the database.
Modifying Modifying Data using the Editor Window
Right click the field you want to modify and select 'Edit' -> 'Edit cell' in the context menu.
This opens a new window that allows you to edit the contents of the data grid field.
Make the necessary modifications in the window and click the Save button.
The editor window disappears, and you are taken back to the data grid. Note that the change indicator on the table tab as well as the highlighted cell indicate the new field value has not been saved to the database.
Click the 'Save' button to save the modified row to the database.
The new field value is saved to the database.
Click the 'Cancel' button to discard changes and revert to the previous state.
Maintenance with SQL Statements
In addition to inline editing, you can maintain the Datastore with SQL statements using DBeaver. This allows you to write SQL statements to insert, update, and delete rows in the Datastore tables. You may find this approach useful when cloning already created data from one Datastore to another Datastore using insert statements or if you need to make mass updates to records within the Datastore.
Open the SQL Editor by selecting 'SQL Editor' -> 'SQL Editor' on the menu bar.
You can open previously saved scripts in the SQL Editor or you can open a new editor window. For this example, I am opening a new SQL Editor window. You can enter SQL statements in the top portion of the editor. Results are displayed in the bottom portion of the editor.
Enter the SQL you want to execute against the Datastore into the editor.
Click the 'Execute SQL Statement' button when ready to execute the SQL statement.
Results are displayed in the bottom portion of the SQL Editor.
Return to the data grid and refresh the grid to see the changes after running the SQL statement in the SQL Editor.
Comments
0 comments
Article is closed for comments.