Test Design StudioGo to Previous Topic: Customizing TemplatesGo to Next Topic: Replacement Parameters

Template Files

Test Design Studio uses specially formatted XML-based files for defining the content of a template. A similar format is used for all three types of templates: Solution, Project, and Item. All template files are stored with the file extension of tdstemplate and must be given the same name of the directory where the template data is located (i.e. a Unified Functional Testing Function Library template might use a directory called FunctionLibrary to store the data and the template file stored in the FunctionLibrary directory must be called FunctionLibrary.tdstemplate).

For the purposes of this documentation, references to the 'source' file refer to the file data stored with the template. References to the 'target' file refer to the new file that is generated when a template is created.

TDSTemplate Element

[XML] - Copy Code
<TDSTemplate Version="1.0.0" Type="Item">
  <TemplateData/>
  <TemplateContent/>
</TDSTemplate>      

The root element of the template file is the TDSTemplate node. This element must be present and supports the following attributes:
Attribute NameDescription
Version(Required) The version of the template file (i.e. 1.0.0).
Type(Required) Specifies the type of template defined in the file. Possible values are: ProjectGroup (i.e. Solution), Project, or Item.

The TDSTemplate element has two child elements: TemplateData and TemplateContent.

TemplateData Element

The TemplateData element is used to describe the template. The following child elements are used to define the template:
Child ElementDescription
Name(Required) The name given to the template.
Description(Optional) A brief description of the template.
DefaultName(Required) The default name given to new items created from this template.
DisplayPriority(Optional) A numerical value indicating the display priority (i.e. sort order) of templates. Lower values are displayed first. Items of the same priority will be sorted alphabetically.
LargeIcon(Optional) The name of the ICO file containing a 32x32 icon for the template.
SmallIcon(Optional) The name of the ICO file containing a 16x16 icon for the template.
AllowNameChange(Optional) Set to true to allow the user to change the name of the item created from the template. Set to false to force the user to use the name provided by the DefaultName element. Default value is true.
ProjectType(For Item Type Only, Required) The Type ID of the development environment to which an item template applies (i.e. QTP for Unified Functional Testing).
BuildAction(For Item Type Only, Optional) Specifies the default build action to apply to a file. Available options include 'Default', 'Process', and 'None'.
LocationField(For Project Type Only, Optional) Specifies the default location for the project to be created from the template.
EnableLocationBrowseButton(For Project Type Only, Optional) Set to true to allow the user to select a different location for the new project. Set to false to force the user to use the location provided by the LocationField element. Default value is true.
CreateNewFolder(For Project Type Only, Optional) This option only applies to Project templates that are linked by a ProjectGroup template. When set to true, a new folder will be created to store the project. When set to false, the project will be created in the same directory as the solution. Default value is false.
NumberOfParentCategoriesToRollUp(For Project Type Only, Optional) An integer value indicating the number of parent categories that this item will be displayed in. For instance, set this value to 1 and the template will be displayed in both the intended category and the parent category. Default value is 0.

TemplateContent Element

The TemplateContent element is used to define the actual content of the template. The following child elements are used to define the template:
Child ElementDescription
CustomParameters

This element allows you to define your own custom parameters to be used while creating the template. The entries you define here are added to the list of built-in replacement parameters. This feature is most often used when creating a Project template that contains complex data. If you have a value that is used throughout a template that is subject to change, you can use a custom parameter to define that data. If the data later changes, you only need to update the replacement value of the custom parameter.

You define each custom parameter by creating a child element called CustomParameter. This element then has two required child elements: Name and Value. The Name element defines the name to give to the custom parameter. While not required, the name should begin and end with the $ character to be consistent with built-in replacement parameters. The Value element specifies the text that replace every occurrence of the Name element. You may also use replacement parameters when defining this value.

The following example illustrates a basic custom parameter called $product_name$ used to store the name of a product. The other parameter called $custom_time$ creates a custom parameter to represent time in a certain format. This custom parameter utilizes other built-in parameters for determining the content.

[XML] - Copy Code
<CustomParameters>
    <CustomParameter>
        <Name>$project_name$</Name>
        <Value>Test Design Studio</Value>
    </CustomParameter>
    <CustomParameter>
        <Name>$custom_time$</Name>
        <Value>$hour$:$minute$:$second$ $time-ampm$</Value>
    </CustomParameter>
</CustomParameters>        
ProjectItem

(For Project and Item Types Only) Defines a file to be copied from the template to the target. The body of the element should contain the name of the file from the template folder. When creating an Item template, the ProjectItem element may appear as a child element to the TemplateContent element or the Folder element. When creating a Project template, the ProjectItem element may appear as a child element to the Project element or the Folder element.

The ProjectItem element supports the following attributes:
Attribute NameDescription
TargetFileName (Optional) The name to give the file after it is copied to the target location. You may use replacement parameters when defining the name (i.e. $fileinputname$.txt). If this attribute is not specified, the name of the file is not changed.
Note:   A special exception exists when renaming target files. When the base name of the source file is the same as the TemplateData/DefaultName element, the file will be automatically renamed based on the $fileinputname$ replacement parameter.
ReplaceParameters(Optional) If the content of the source file contains replacement parameters, you must set this attribute to true to mark this file for processing. If this attribute does not exist or is set to false, the content of the file will not be modified when it is copied to the target location.
OpenInEditor(Optional) Set this attribute to true to instruct Test Design Studio to open the specified file after creating the template. Default value is false.

Folder (For Project and Item Types Only) Defines a folder to be created on the target. A Folder element may contain child ProjectItem elements to define source files that will be copied to the target.

The Folder element supports the following attributes:
Attribute NameDescription
Name(Required) The name of the source folder.
TargetFileName(Optional) The name to give the folder after it is copied to the target location. You may use replacement parameters when defining the name. If this attribute is not specified, the name of the folder is not changed.

Project (For Project Type Only) Defines the project file to be created on the target. A Project element may contain child Folder and ProjectItem elements to define source files that will be copied to the target and included in the project.

The ProjectItem element supports the following attributes:
Attribute NameDescription
File(Required) The name of the project file to be copied to the target.
TargetFileName (Optional) The name to give the project file after it is copied to the target location. You may use replacement parameters when defining the name (i.e. $projectname$.qtpproj). If this attribute is not specified, the name of the file is not changed.
ReplaceParameters(Optional) If the content of the source file contains replacement parameters, you must set this attribute to true to mark this file for processing. If this attribute does not exist or is set to false, the content of the file will not be modified when it is copied to the target location.

ProjectCollection

(For ProjectGroup Type Only) Defines the individual projects to be included in a solution. For each project, a ProjectTemplateLink child element must be created.

The body of the ProjectTemplateLink element indicates the name of the project template file (*.tdstemplate) to process. The ProjectTemplateLink also supports the following attributes:
Attribute NameDescription
ProjectName(Required) The name to assign to the project.

The following sample code illustrates the use of this element:

[XML] - Copy Code
<ProjectCollection>
  <ProjectTemplateLink ProjectName="WinRunner">.\WinRunner\WinRunner.tdstemplate</ProjectTemplateLink>
  <ProjectTemplateLink ProjectName="QuickTest Pro">.\QuickTest Pro\QuickTest Pro.tdstemplate</ProjectTemplateLink>
</ProjectCollection>

Sample File

The following shows the XML content of sample Item template file:

[XML] - Copy Code
<TDSTemplate Version="1.0.0" Type="Item">
  <TemplateData>
    <Name>Name Of Template</Name>
    <Description>This is an example of a template file</Description>
    <DefaultName>NewFile.txt</DefaultName>
    <ProjectType>ID</ProjectType>
    <DisplayPriority>10</DisplayPriority>
  </TemplateData>
  <TemplateContent>
    <ProjectItem>NewFile.txt</ProjectItem>
  </TemplateContent>
</TDSTemplate>

For more detailed examples of Solution, Project, and Item templates, review the built-in templates that are provided with Test Design Studio. These templates are installed to the <Install Dir>\ProjectTemplates and <Install Dir>\ItemTemplates directories.