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 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(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(typeof(Properties.Resources), "MyTest_Timeout")]
    public double Timeout
    {
        get { return m_timeout; }
        set { m_timeout = value; }
    }

See Also

Concepts

Implementing Custom Test Types

How to: Implement a Basic Test Type