TestOptimal Wiki

Model-Based Testing (MBT)

User Tools

Site Tools


Model Triggers

Triggers are the events fired/executed at certain point in the model execution. You can attach MScript or java method to each trigger. When the trigger fires, the MScript or java method attached will be executed.

Triggers can be used to format and output test cases to files or used to drive AUT for test automation or both.


Understanding when triggers are fired can help you determine which trigger your automation script (MScript or java method) should be attached to.

Some triggers are fired at the beginning of the model execution, some are fired at the specific state or transition and some are generic triggers fired for any state/transition. Below you will find more information about these triggers. They are listed in the order relevant to the order in which they are fired:

  • MBT_start - start of model execution.
  • On Entry - upon entry to the state
  • Porocess - state process trigger.
  • On Exit - on exiting state, usually used to perform some cleanup or updating database, etc.
  • Guard - transition guard trigger, used to define transition constraints
  • Prep - prepare transition, usually used to set values to fields, select options for the lists, etc.
  • Action - transition action trigger, usually used to click on a button or link that caused the state to change.
  • Verify - transition verify trigger, usually used to check fields on the page to confirm the action was performed correctly.
  • MBT_end - executed at the end of model execution to perform teardown/cleanup for the execution.
  • OnException - executed on any exception/failure. Exceptions/Failure usually does not stop the execution, instead they are tracked and logged with the corresponding state/transition.
  • OnError - executed on any runtime error which stops the execution.
  • User Defined Function - user defined functions can be called from mscript using $callFunc('funcName')

Execution Order

Triggers are executed in the predefined order as the states and transitions are traversed by the sequencers.

MBT Start trigger is executed at the beginning of each model execution and is only executed once per model execution.

MBT End trigger is executed at the end of the each model execution and is only executed once per model execution.

State and transition triggers are executed between MBT Start and MBT End as the states and transitions are traversed.

When state is traversed, the following state triggers are executed in order:

  • On Entry
  • Proess
  • On Exit

Upon state is traversed, a transition is chosen to be traversed. The transition triggers are exeuted in the following order:

  • Guard
  • Prep
  • Action
  • Verify

Guard trigger is executed for all transitions leaving the state to evaluate which transition is feasible before choosing a transition. Once the transition is chosen, the transition triggers of the chosen transition are then executed in the order described above.

You may also define OnException and OnError triggers to handle test failures (Exceptions) and runtime errors (coding error).

triggers.txt · Last modified: 2017/10/29 16:31 by admin