TestOptimal Wiki

Model-Based Testing (MBT)

User Tools

Site Tools



while tag is similar to if tag, it executes the command tags in its body until the condition evaluates to false.


The syntax for while tag is:

  <while value1="expression1" op="comparator" value2="expression2"
         maxLoopNum="expression3" loopVar="varName">
     <!-- add other command tags --!>

if tag shares most of the attributes with assert tag.

maxLoopNum is used to set a limit of number of loops for the while loop. This is useful to avoid infinite loop due to false logic. Usually you would assign a numeric number, but you may also use mscript expression. Set it to 0 or blank to remove this restriction.

loopVar (rel 3.1.18) when set will create the user variable with the name specified in its value and its value populated with the loop count (starts at 0). See example:

  <action code="$setVar('var1', '1')"/>
  <while value1="$getVar('var1')" op="lt" value2="10" maxLoopNum="5" loopVar="loopCount">
      <log msg="var1: $increment('var1'), loopCount: $getVar('loopCount')"/>
whiletag.txt · Last modified: 2016/09/22 02:36 (external edit)