Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
tutorial:scripting_comb_data_model [2020/07/18 02:40] – [Tutorial: Automation Scripting - Combinatorial Model] admintutorial:scripting_comb_data_model [2024/01/03 19:54] (current) – removed admin
Line 1: Line 1:
-====== Tutorial: Automation Scripting - Combinatorial Model ====== 
- 
-Learning Objectives: 
-  * Model scripting 
-  * Looping through DataTable 
-  * Activating plugins 
-  * Persisting and exporting results 
- 
-This tutorial assumes that you are familiar with how to create a Combinatorial Data Model and have created a simple model with at least 2 variables named Field1 and Field2 and have generated the DataTable.  Please refer to [[tutorial_comb_data_model | Combinatorial Data Modeling]] if you need assistance in creating the model. 
- 
- 
-===== Model scripting ===== 
-[[https://groovy-lang.org/syntax.html | Apache Groovy]] script is the scripting language for your models.   
- 
-//Groovy// script is syntactically very similar to most of programming language that allows you to create classes, functions and basic logic and arithmetic operations. 
- 
-Unlike [[scripting_state_model | scripting for State Model]], you just write your script right in [[../data_design_ide#script | SCRIPT]] tab. In your script you would just loop through the rows in DataTable.  Below is an example of script: 
- 
-   $DATASET.notifyClient('Total number of rows in DataTable: ' + $DATASET.getDataRows().size()); 
- 
-Run the model, you should see 'Total number of rows in DataTable: 10' on IDE. 
- 
-===== Activating Plugins ===== 
-Just like [[scripting_state_model | scripting for State Model]], you need to activate plugins to interact with AUT to perform the testing on each row in the DataTable. 
- 
-For this tutorial, activate //Random// plugin, and modify the script to use //$RANDOM.randNum(...)// to determine the failure/success as below: 
- 
-   for (Map<String,String> row: $DATASET.getDataRows()) { 
-      if ($RANDOM.randNum(0,10) > 5) { 
-         row._result = "Successful run on " + row.Field1 + ", " + row.Field2; 
-         row._status = true; 
-      } 
-      else { 
-         row._result = "Failed run on " + row.Field1 + ", " + row.Field2; 
-         row._status = false; 
-      } 
-      $DATASET.notifyClient(row); 
-   } 
- 
- 
-