forand press Tab to insert the code of a 'For' loop).
When a snippet is activated, the text for the snippet is automatically placed within the editor and your selection moves to the first field in the snippet. Fields are used to mark portions of the snippet that should be easily modified by the user. For example, the following code snippet shows a VBScript property declaration for a class complete with a backing field:
Tip: If text is selected in the editor when a snippet is activated and that snippet supports surrounding text, the selected text will be embedded in the snippet. Activating a
forsnippet, for instance, will take the selected text and move it to the body of the
In the sample above, you have four fields;
VariableName field occurs three times,
PropertyName occurs three times,
ByVal occurs only once, and
vData occurs twice. You will notice
VariableName field is currently active, the two additional dependent fields are denoted with a dashed border. If the value of a field is modified, all dependent fields are updated to refelect the same value. The ability to modify one field and have all dependent fields instantly updated to match
is what gives code snippets their power and elevates them above basic template text that is inserted by editors such as Unified Functional Testing.
|Tab||When the caret is positioned inside an active field, the Tab key will move you to the next field. The text of that field will be automatically selected so that it can be easily replaced.|
|Enter||When the caret is positioned inside an active field, the Enter key will exit code snippet mode and move the caret to the end position of the snippet (this is defined by the |
|Esc||Exits code snippet mode without modifying the location of the caret.|
The typical process for populating a code snippet is the following:
|Insert Snippet||Displays the Insert Snippet popup allowing you to type or select a code snippet to insert.|
|Surround With||Displays the Surround With popup allowing you to type or select a code snippet to insert. Only snippets that support surrounding text will be displayed.|
The following prompt is displayed when the Insert Snippet command is executed.
A form with equivalent functionality is displayed for the Surround With command except only snippets support surrounding text will be displayed.
A member list will be displayed showing all the available snippets. You may type directly in the prompt to quickly access the snippet, or you may use a combination of the cursor keys and mouse to select a snippet. Code snippets can be grouped by folders for organization, so you may need to first select a folder to find the appropriate code snippet.
Code Snippets are maintained by the Code Snippet Manager (accessed by selecting Tools -> Code Snippet Manager from main menu).
Code snippets are targeted for a specific language and organized by folders. Select the desired language from the drop-down list of languages and the available code snippets will be displayed. Select any folder or code snippet to see the location of the respective item in the Location textbox. You may also select any code snippet to view details about the item in the right pane.
The structure of folders is maintained in a browsable state when you use the Insert Snippet or Surround With IntelliSense options.
By default, there will always be a built-in folder for each language, and it cannot be removed. There will also be a My Code Snippets folder that is intended for the storage of personal code snippets (select the My Code Snippets folder and the Location textbox will reveal the path to the folder). This folder is pre-defined for convenience and may be easily removed. If a folder appears with an exclamation mark over the icon, that folder does not exist on the file system and can be removed if desired. You can always add your own folder to the language by clicking the Add button and browsing to the folder you wish to add.
Code snippets are special files stored on the file system. You can use the Add button to add any folder to the currently selected language. This will automatically import all code snippet files from that folder as well as recursively add the snippet files from any sub-folders (if present). Since all sub-folders are automatically imported, you will only need to add the top-most folder.
To remove a user-defined folder, highlight the top-most folder and click the Remove button. The child folders of a top-most folder may not be individually removed since they are auto-imported with the top-most folder. To remove a child folder, you would need to physically remove it from the file system to prevent it from being automatically imported.
Note: Built-in folders cannot be removed.
Tip: The name of a code snippet folder is derived from the name of the folder on the file system. You can override the name of a folder or sub-folder by placing a
SnippetDir.xmlfile within that folder. The contents of that file should read as:[XML] - Copy CodeThis will override the name of the folder with the name specified in the file. This is especially useful when multiple folders of the same name are added for a language so that you can differentiate between the folders.<SnippetDir> <Name>Specify New Name of Folder</Name> </SnippetDir>
Code snippet data is cached when the application is launched. If any changes are made to snippet files or the underlying file system, you must select the respective folder and click the Refresh button to updated the cached data.
To quickly edit any code snippet, select the code snippet you would like to edit and click the Open Snippet button. The Code Snippet Manager will close, and the selected code snippet will be opened in the Code Snippet Editor.
To create a new code snippet in an existing folder, first select the desired folder or select any code snippet that is already contained within the desired folder. Then click the New Snippet button. You will be prompted to provide a file name for the new snippet, the Code Snippet Manager will close, and the new snippet will be opened in the Code Snippet Editor. Set the necessary information and save your new code snippet. It will become immediately available to Test Design Studio.
Tip: The language
Unified Functional Testingis a derivatives of the
VBScriptlanguage. As a result, all
VBScriptcode snippets will always be available to the
Unified Functional TestingProlanguage. Any code snippets that are generic to VBScript should be placed under the
Unified Functional Testinglanguage should include snippets specifically for use with Unified Functional Testing.
Tip: The snippet files used by Test Design Studio are fully compatible with most snippet files used by Microsoft®'s Visual Studio. Therefore, files created for use in Visual Studio may also be used within Test Design Studio. Visual Studio snippet files using function references are not supported by Test Design Studio.