Share via


Using Optional TestElement Properties

When you implement the TestElement class, you can also use two optional attributes, PersistenceElementName and UserVisibleProperty.

PersistenceElementName Attribute

Use this attribute to tell the XML Reader/Writer what XML name to use when serializing the property for you. Use this if you plan to take advantage of this XML class when you load or save tests in ITip.Load() and ITip.Save().

Syntax

[PersistenceElementName("<NAME_OF_PROPERTY>")]

Example

Place the PersistenceElementName attribute on the line just before the declaration of one of your custom properties (class variables).

    <PersistenceElementName("Timeout")> _
    Private timeout As Double
    [PersistenceElementName("Timeout")]
    private double timeout;

UserVisibleProperty, DefaultValue, and TestCaseManagementDisplayName Attributes

The UserVisibleProperty determines whether the test property appears for the test in the Properties window.

Use the DefaultValue attribute to set a default value to use if the field in the test property has no value.

Use TestCaseManagementDisplayName to set a localizable name to use in the Properties window.

Syntax

<UserVisibleProperty("<GUID>"), _
TestCaseManagementDisplayName(GetType(Properties.Resources), "<NAME_OF_RESOURCE_STRING>"), _  
DefaultValue("<SOME_VALUE>")> _
[UserVisibleProperty("<GUID>")]
[TestCaseManagementDisplayName(typeof(Properties.Resources), "<NAME_OF_RESOURCE_STRING>")]
[DefaultValue("<SOME_VALUE>")]

Examples

Place these properties just before the get method. For example:

    <UserVisibleProperty("<GUID>"), _
    DefaultValue(""), _
    TestCaseManagementDisplayName(GetType(Properties.Resources), "MyTest_Timeout")> _
    Public Property Timeout() As Double
        Get
            Return m_timeout
        End Get
        Set(ByVal value As Double)
            m_timeout = value
        End Set
    End Property
    [UserVisibleProperty("<GUID>")]
    [DefaultValue("")]
    [TestCaseManagementDisplayName(typeof(Properties.Resources), "MyTest_Timeout")]
    public double Timeout
    {
        get { return m_timeout; }
        set { m_timeout = value; }
    }

See Also

Tasks

How to: Implement a Basic Test Type

Other Resources

Implementing Custom Test Types