IDE & Navigation
Properties & Tools
comment tag is used to comment/document your MScript.
There are two ways to add comments to mscript: comment attribute and xml comment tag.
<if value1="$rand()" op="le" value2="0.5" comment="short comment1"> <!-- this is a long comments that may span multiple lines. --> <action code="$click('abc')" comment="short comment2"/> </if>
In the above example, if tag has a short comment “short comment”. Inside if, there is a 2-line comment right before action tag which also has a short comment “short comment2”.
The short comment entered in comment attribute is also used as the display label in Program Structure Diagram.
There is another use of comments besides being used to document your MScript. You may also use it to produce the test execution results by having them written out to a file as the MScript is executed. Because the comments can be nested inside another MScript tags, the comment will only be written (executed) when the enclosing MScript tag is executed. Essentially this is equivalent to placing log messages.
There are two ways to enable writing comments (xml comment tag) to a file:
You may use any mScript functions inside the comments. They will be executed if write comments to file is enabled. This gives you the ability to construct the comment text to be written out to the file just like log message.
<if value1="$getTitle()" op="eq" value2="Product List"> <then> <!-- We landed at "Product List" page. Passed at Transition [curTransEvent], Requirement tag [curTransTags] --> <action code="$addTagCheck('[curTransTags]', 'passed')"/> </then> <else> <!-- We landed at "$getTitle()" page, expecting "Product List". Failed at Transition [curTransEvent], Requirement tag [curTransTags] Traces that led to this failure: Traversal Path: @a width='100%'|$genPath('failurreTraceSeq')@ Sequence Diagram: @a|$genMSC('Product List Page Failure', 'failureTraceMSC')@ --> <action code="$addTagCheck('[curTransTags]', 'failed')"/> </else> </if>
In the above example, assuming current transition name is clickMain and requirements tag associated with the transition is “R_1; R_2”, it will print the following to the file if if tag evaluates to true:
We landed at "Product List" page. Passed at Transition clickMain, Requirement tag R_1; R_2
or print the following if if evaluates to false (say landed on Item Detail page):
We landed at "Item Detail" page, expecting "Product List" Failed at Transition clickMain, Requirement tag R_1; R_2 Traces that led to this failure: Traversal Path: http://testoptimal.com/img/failureTraceSeq.png Sequence Diagram: http://testoptimal.com/img/failureTraceMSC.png
The above information written to the file would capture the test result success or failures and the graphs produced above would provide the documentation of the test results as well as useful information you can pass to the developer to reproduce the failure.