Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

TestCleanupAttribute Class

 

Identifies a method that contains code that must be used after the test has run and to free resources obtained by all the tests in the test class. This class cannot be inherited.

Namespace:   Microsoft.VisualStudio.TestTools.UnitTesting
Assembly:  Microsoft.VisualStudio.QualityTools.UnitTestFramework (in Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll)

System::Object
  System::Attribute
    Microsoft.VisualStudio.TestTools.UnitTesting::TestCleanupAttribute

[AttributeUsageAttribute(AttributeTargets::Method, AllowMultiple = false)]
public ref class TestCleanupAttribute sealed : Attribute

NameDescription
System_CAPS_pubmethodTestCleanupAttribute()

Initializes a new instance of the TestCleanupAttribute class.

NameDescription
System_CAPS_pubpropertyTypeId

(Inherited from Attribute.)

NameDescription
System_CAPS_pubmethodEquals(Object^)

(Inherited from Attribute.)

System_CAPS_pubmethodGetHashCode()

(Inherited from Attribute.)

System_CAPS_pubmethodGetType()

(Inherited from Object.)

System_CAPS_pubmethodIsDefaultAttribute()

(Inherited from Attribute.)

System_CAPS_pubmethodMatch(Object^)

(Inherited from Attribute.)

System_CAPS_pubmethodToString()

(Inherited from Object.)

The method marked with this attribute will be run after methods marked with the TestMethodAttribute and before methods marked with the ClassCleanupAttribute and AssemblyCleanupAttribute.

This attribute can be specified on a method. Only one instance of this attribute may be applied to a method.

By default, this attribute is used in generated code.

For more information about how to use attributes, see Extending Metadata Using Attributes.

Legacy Code Example

The SampleClassLib namespace contains the DivideClass class, which in turn contains the method we want to test. This method is called DivideMethod().

No code example is currently available or this language may not be supported.

In the following code, the DivideClassTest test class contains a test method called DivideMethodTest. This code also contains attributes that control the initialization and clean-up execution order for the method, class, and assembly.

In particular, note the TestCleanup attribute on the Cleanup() method.

No code example is currently available or this language may not be supported.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show: