TestOptimal Wiki

Model-Based Testing (MBT)

User Tools

Site Tools


MScript - XML Based Scripting

MScript is an XML based scripting to either directly drive your application under test (AUT) or generate testing script to be executed or read later for offline testing in any programming language syntax.

MScript Tags

  • action - executes the action specified in the code attribute, e.g. to click the button named Order, you would enter code=“click('name=Order')”. See mScript function. You may also create your own User Defined Functions.
  • assert - asserts the condition specified. if condition fails throw the MBTException.
  • comments - comments for any mScript tags. Also see comment attribute for all tags.
  • dataset - defines a dataset. Its body contains tags that populates the dataset.
  • db - defines a jdbc data source to be used by sql tag.
  • execSQL - executes an sql statement.
  • field - defines a field in a row and sets its value.
  • guard - defines a constraint for the conditional transition/edge
  • if - performs condition check and if evaluates to true then execute the command tags in the body.
  • log - logs a message to TestOptimal server log file.
  • mbt - container tag to hold one or many scripts to control MBT execution.
  • rowdata - adds a row to the data set. Must be within a dataset tag and contain at least one field tag.
  • script - defines a script method to be executed at state entry/exit or transition prep, action or verify. The body of the script tag is the command tags. This tag is equivalent to the method declaration in a java class.
  • scriptlet - executes a list of Selenium IDE Script (copy tbody content from Selenium IDE).
  • seqout - writes to seq.out. use this tag to create the test script/code to be read or executed in other test automation tool. (Release 3.0)
  • sql - declares the sql statement to populate dataset.
  • state - container tag to hold scripts for a state including transition.
  • transition - container tag to hold scripts for a transition.
  • while - executes the script in its body if the condition specified is true.

Commenting MScript

There are two ways you can comment your MScript: as an attribute comment for short comments or as a separate child tag comments for multi line comments.


MScript supports two types of variables: system variables and user variables.

Both types of variables can be retrieved using a concise form: [varName].

For example:

  • [curStateID] - equivalent to $getSysVar('curStateID')
  • [var1] - equivalent to $getVar('var1')

Macro Tokens

Besides user variables, you may define a set of macro to be used to construct dynamic content. You can then reference these tokens with [@tokenName], for example:


The macro tokens are defined in token.properties in config folder. It is a java properties file with format of code=value.

mscripttags.txt · Last modified: 2016/09/22 02:36 (external edit)