Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
tutorial:hybrid_model [2020/12/30 22:59] admin [Add Data Sets to Model] |
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 45: | Line 46: | ||
==== Create State Model ==== | ==== Create State Model ==== | ||
- | First create a state model with a transition named "checkout", the transition we will use to attach data sets to. If you need help creating the state model, you may refer to [[state_modeling | Create State Model tutorial]]. | + | First create a state model with a transition named "CheckOut", the transition we will use to attach data sets to. |
+ | |||
+ | {{wiki: | ||
+ | |||
+ | If you need help creating the state model, you may refer to [[state_modeling | Create State Model tutorial]]. | ||
You can also use any of your existing state model as well, just select a transition from the model which we will attach the data sets. | You can also use any of your existing state model as well, just select a transition from the model which we will attach the data sets. | ||
Line 134: | Line 140: | ||
==== Attach Data Set to Transition ==== | ==== Attach Data Set to Transition ==== | ||
+ | |||
+ | In this step, we will attach the data set " | ||
+ | |||
+ | Open the transition properties by double-clicking on the transition label or through transition context menu and select " | ||
+ | |||
+ | {{wiki: | ||
+ | |||
+ | When a data set is attached to the transition, the sequencer that generates test cases from the model will ensure the test cases generates will cover the transition the number of times to loop through all of the rows in the data set. | ||
+ | |||
+ | Save the changes. | ||
+ | |||
+ | ==== Generate Test Cases ==== | ||
+ | |||
+ | Select " | ||
+ | |||
+ | The best way to show this is through {{wiki: | ||
+ | |||
+ | Notice that in {{wiki: | ||
+ | |||
+ | 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 " | ||
+ | |||
+ | {{wiki: | ||
+ | |||
+ | IDE should navigate to //SCRIPT// tab. Since the TRIGGER for transition " | ||
+ | |||
+ | {{wiki: | ||
+ | |||
+ | Click " | ||
+ | |||
+ | {{wiki: | ||
+ | |||
+ | 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 " | ||
+ | |||
+ | {{wiki: | ||
+ | |||
+ | |||
+ | |||
+ | TRIGGER script is just a //groovy// function, go ahead and add two lines of scripts as show below: | ||
+ | |||
+ | {{wiki: | ||
+ | |||
+ | |||
+ | The " | ||
+ | |||
+ | Save the changes and run the model again. Examine //Script Log// (click on the script log button {{wiki: | ||
+ | |||
+ | Below is the first few lines from the script log: | ||
+ | |||
+ | | ||
+ | |||
+ | >>> | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | |||
+ | |||
==== Loop through Data Set ==== | ==== Loop through Data Set ==== | ||
+ | The data set can also be looped programmatically by scripting as follows: | ||
+ | | ||
+ | |||
+ | // rewind dataset to first row | ||
+ | | ||
+ | |||
+ | // retrieve data | ||
+ | | ||
+ | |||
+ | // advance to next row, if rowIdx == 0, all rows exhausted | ||
+ | | ||
+ | Please note that the data set being looped programmatically as above can not be attached to the transition at the same time. | ||