IDE & Navigation
Properties & Tools
MScript Editor is a full-feature source code editor (xml scripting) that allows you to view and edit MScript for each trigger point or MScript for the entire model.
It offers code-assist (ctrl-space), syntax highlight, search/replace, undo/redo, code collapse/expand, set breakpoint for debugging. It can also generate Program Structure Diagram for the trigger script as well as Call Hierarchy Diagram.
During and after model execution, it can display the script test coverage.
MScript Editor is a tab which can be placed in any of the 3 panes. By default, MScript Editor is placed in the bottom right pane.
When you click /select a state or transition, MScript Editor automatically loads the MScript for the corresponding state or transition.
Changes are automatically pushed to the server when you move focus to other tabs in the IDE.
There are many System Defined Triggers for each state, transitions as well at model level. You can write MScript for each of these triggers by selecting the trigger name from the drop-down list of triggers.
You may also view / edit MScript for the entire model by selecting the model in the trigger drop-down list.
Editor allows you to check MScript syntax. To do so, click . The error will be highlighted and there will be a set of buttons on the editor header to let you navigate through all errors (previous and next).
You may also create your own trigger using User Defined Trigger. To define a User Define Trigger, hover mouse over on the upper right corner of the editor and select Add Trigger. You will be prompted to name the trigger.
The new trigger will be added to the trigger drop-down list available for you to choose to add MScript.
You can generate Program Structure Diagram for the selected trigger. Program Structure Diagram is a good way to visualize MScript. It helps you to get an overall view of your MScript and make it much easier to find coding mistake and logic errors.
To generate the Program Structure Diagram, hover mouse over on the upper right corner of the editor and select Program Structure Diagram option. The Program Structure Diagram should open in a separate browser window (or browser tab).
MScript provides a function to call another trigger. This allows you to execute same trigger from different triggers. You can generate the call hierarchy diagram that describes the flow of triggers calling other triggers.
To generate the Trigger Call Hierarchy Diagram, edit the trigger which you want to use as the starting trigger in Trigger Call Hierarchy Diagram. Then mouse over on the upper right corner of the editor and select Call Hierarchy Diagram option. The Trigger Call Hierarchy Diagram should open in a separate browser window (or browser tab).
You may create User Defined Functions that can be called anywhere in the model. These functions are declared in Function trigger.
MScript editor supports MScript Editor Shortcut Keys that allow you to perform basic editor functions with keyboard keys, e.g. ctrl-F for find, ctrl-Space for code-assist, etc.
Code Assist is supported. By pressing ctrl-space, a popup list is displayed showing the list of suggested MScript functions or constants that can be inserted into the editor or replace the selected MScript text in the editor. Code Assist is context sensitive, that is, the content of the list displayed is dependent on what element the cursor is currently on in the editor.
For example, if the cursor is on a blank line, the Code Assist list will be populated with list of MScript tags. If the cursor is inside the op attribute of a assert tag, then the popup list will be populated with compare operators available: eq, lt, gt, etc.
Below are the description of different Code Assist context supported with ctrl - space pressed:
With ctrl-space, it brings up a list of Mscript functions that include both system functions and plugin functions as noted in the header of the popup. Alternatively you may use ctrl-S to bring up just system functions and ctrl-p to bring up just plugin functions.
Search and Replace is displayed right above the editor area when invoked. You may close Search and Replace by clicking on the close control on the far right or clicking anywhere in the while space area within Search and Replace.
You must run the search first, once you've found the first match, you may then replace the matched text (selected) with the replacement string.
There are different search criteria supported as described in Search Text section below.
Enter a text into the search field to start the search. As you type search text into the search field, the editor will try to match the text you have entered and highlight the matches automatically with the first matched text highlighted in darker color.
Last searched text is remembered and will be displayed as default value when the Search and Replace is invoked again.
To navigate through the matched texts in the editor, use the two navigation button next to the search field.
While the cursor is in the search text field, you may use Enter or down arrow key to go to next match and up arrow to the previous match.
By default, the search is case sensitive if the search text contains one or more characters in uppercase. To perform case insensitive search, enter the search text in lowercase.
Regular expression search is also supported. To perform regular expression search, enclose the regular expression in a set of forward slash (/) like /[0-9][a-z]/.
When you have found a match with Search, you can enter a replacement text.
As you enter the replacement text, two buttons R and RR will be displayed to the right of the replacement field.
Use the button R to perform the replacement on the current matched text (darker shade) at the same time move the current selection to the next matched text in the direction used in the last search.
Alternatively you can use Enter key to perform the replacement.
While the cursor is in the replacement field, you may use down arrow key to go to next match and up arrow to the previous match without performing the replacement.
Use Search buttons to change the direction for the next replacement.
You may replace all matched texts in the direction of last search by clicking on the RR button.
To replace matched texts in the other direction, just click on one of the search button to find the next match and then click on RR to replace all matched texts.
The number of replacements performed is displayed next to the replacement buttons.
You may define a set of macros to encapsulate a set of frequently used MScript. This is done via editing the CAMacro.properties in config folder.
You may add tooltip to each of the macro by appending @tooltip:my tool tip msg to the end of the macro line.
Macro file CAMacro.properties can include other files by adding the following:
To call up macros, press ctrl+M (or alt+M).
If you have configured the interface to your requirements system, you may bring up a list of requirements by pressing ctrl+R (or alt+R). For more information about how to configure TestOptimal to access your requirements system, please see ALM Configurarion.
<!-- your comments goes here -->
You can set breakpoint on MScript line by clicking on the line number column on the left of the editor. If MScript spans multiple lines, the breakpoint can only be set on the first line of the MScript.
MScript is stored in mscript.xml in the model folder. You can certainly use third party xml editor to edit the MScript. If you do so, be aware that you must save the changes and reload the model in order for TestOptimal to see your changes.
New in release 4.2, the system automatically collects execution coverage of each MScript tag during the model execution. The execution coverage of MScript tags can then retrieved and displayed in editor.
To retrieve MScript coverage metrics, select MScript Coverage from the drop-down menu at the upper-right corner of the editor.
The system collects the number of times each MScript tag is executed. For MScript container tags like if and while that contain other MScript tags, the coverage is also presented.
The coverage metrics are then displayed with two additional MScript attributes: execCount and coverage.