Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
tutorial:hybrid_model [2020/12/31 02:16]
admin [Generate Test Cases]
tutorial:hybrid_model [2021/01/05 03:00] (current)
Line 3: Line 3:
 Learning Objectives: Learning Objectives:
   * Differences between state model and combinatorial model   * Differences between state model and combinatorial model
-  * Hybrid model+  * Hybrid model (embedding combinatorial model in state model) 
  
  
Line 155: Line 156:
  
 The best way to show this is through {{wiki:overview:tut_DataSet_testcaseGraph.png?linkonly | Test Case Graph}} in //RESULT// tab.  The best way to show this is through {{wiki:overview:tut_DataSet_testcaseGraph.png?linkonly | Test Case Graph}} in //RESULT// tab. 
 +
 +Notice that in {{wiki:overview:tut_DataSet_testcaseGraph.png?linkonly | Test Case Graph}}, there are 25 test cases and each test case covers the transition "CheckOut" matching 25 rows in the data set.
 +
 +To confirm that each row in data set is used, let's print out the data row as model runs - the test cases generated and executed. 
 +
 +To write a line of script in TRIGGER for transition "CheckOut", select script context menu for transition "CheckOut":
 +
 +{{wiki:overview:tut_DataSet_menuTransScript.png?250}}
 +
 +IDE should navigate to //SCRIPT// tab.  Since the TRIGGER for transition "CheckOut" has not been created, you will be prompted to create it:
 +
 +{{wiki:overview:tut_DataSet_ScriptAddDialog.png?500}}
 +
 +Click "OK" to create the skeleton TRIGGER script for the transition:
 +
 +{{wiki:overview:tut_DataSet_ScriptCheckOut.png?500}}
 +
 +Alternatively you can add the skeleton TRIGGER script for the transition by pressing Ctrl-I while your cursor is placed on a blank line in //SCRIPT// tab and select transition "CheckOut":
 +
 +{{wiki:overview:tut_DataSet_AddTrigger.png?100}}
 +
 +
 +
 +TRIGGER script is just a //groovy// function, go ahead and add two lines of scripts as show below:
 +
 +{{wiki:overview:tut_DataSet_TriggerCheckOut.png?500}}
 +
 +
 +The "log" scripts above prints the current row of the data set and "Payment Type" and "CardNum" to //Script Log//.
 +
 +Save the changes and run the model again. Examine //Script Log// (click on the script log button {{wiki:overview:tut_DataSet_ScriptLogBtn.png?50}} in //RESULT// tab):
 +
 +Below is the first few lines from the script log:
 +
 +   C:\eclipse-workspace\TestOptimal_Dev\model\Demo_DataSet.fsm\temp\script.log
 +   
 +   >>> Date: 2020-12-30 
 +   20:51:25.915 data row [0]: [PaymentType:VISA, CardNum:4111-1111-1111-1111, Warranty:false, Shipping:0, PromoCode:Blank, $$hashKey:object:444]
 +   20:51:25.916 PaymentType: VISA, CardNum: 4111-1111-1111-1111
 +   20:51:25.917 data row [1]: [PaymentType:VISA, CardNum:4111-1111-1111-1111, Warranty:true, Shipping:1, PromoCode:10%OFF, $$hashKey:object:445]
 +   20:51:25.918 PaymentType: VISA, CardNum: 4111-1111-1111-1111
 +   20:51:25.918 data row [2]: [PaymentType:VISA, CardNum:4111-1111-1111-1111, Warranty:false, Shipping:2, PromoCode:20%OFF, $$hashKey:object:446]
 +   20:51:25.918 PaymentType: VISA, CardNum: 4111-1111-1111-1111
 +   20:51:25.919 data row [3]: [PaymentType:VISA, CardNum:4111-1111-1111-1111, Warranty:false, Shipping:0, PromoCode:$5OFF, $$hashKey:object:447]
 +   20:51:25.919 PaymentType: VISA, CardNum: 4111-1111-1111-1111
 +   20:51:25.919 data row [4]: [PaymentType:VISA, CardNum:4111-1111-1111-1111, Warranty:true, Shipping:0, PromoCode:15$OFF, $$hashKey:object:448]
 +   20:51:25.919 PaymentType: VISA, CardNum: 4111-1111-1111-1111
 +   20:51:25.919 data row [5]: [PaymentType:MASTER, CardNum:5500-0000-0000-0004 , Warranty:true, Shipping:1, PromoCode:Blank, $$hashKey:object:449]
 +   20:51:25.919 PaymentType: MASTER, CardNum: 5500-0000-0000-0004 
 +   20:51:25.920 data row [6]: [PaymentType:MASTER, CardNum:5500-0000-0000-0004 , Warranty:false, Shipping:2, PromoCode:10%OFF, $$hashKey:object:450]
 +   20:51:25.920 PaymentType: MASTER, CardNum: 5500-0000-0000-0004 
 +   20:51:25.920 data row [7]: [PaymentType:MASTER, CardNum:5500-0000-0000-0004 , Warranty:true, Shipping:0, PromoCode:20%OFF, $$hashKey:object:451]
 +   20:51:25.920 PaymentType: MASTER, CardNum: 5500-0000-0000-0004 
 +   20:51:25.921 data row [8]: [PaymentType:MASTER, CardNum:5500-0000-0000-0004 , Warranty:false, Shipping:1, PromoCode:$5OFF, $$hashKey:object:452]
 +   20:51:25.921 PaymentType: MASTER, CardNum: 5500-0000-0000-0004 
 +   20:51:25.921 data row [9]: [PaymentType:MASTER, CardNum:5500-0000-0000-0004 , Warranty:false, Shipping:0, PromoCode:15$OFF, $$hashKey:object:453]
 +   20:51:25.921 PaymentType: MASTER, CardNum: 5500-0000-0000-0004 
 +   20:51:25.922 data row [10]: [PaymentType:DISCOVER, CardNum:6011-0000-0000-0004, Warranty:true, Shipping:0, PromoCode:Blank, $$hashKey:object:454]
 +   20:51:25.922 PaymentType: DISCOVER, CardNum: 6011-0000-0000-0004
  
  
Line 161: Line 221:
 ==== Loop through Data Set ==== ==== Loop through Data Set ====
  
 +The data set can also be looped programmatically by scripting as follows:
 +   dataset = $SYS.getDataSet('PaymentOptions');
 +   
 +   // rewind dataset to first row
 +   dataset.rewind();
 +   
 +   // retrieve data
 +   paymentType = dataset.getData('PaymentType');
 +   
 +   // advance to next row, if rowIdx == 0, all rows exhausted
 +   rowIdx = dataset.nextRow();
  
 +Please note that the data set being looped programmatically as above can not be attached to the transition at the same time.