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.
Assembly: Microsoft.VisualStudio.QualityTools.UnitTestFramework (in Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll)
| Name | Description | |
|---|---|---|
![]() | TestCleanupAttribute() | Initializes a new instance of the TestCleanupAttribute class. |
| Name | Description | |
|---|---|---|
![]() | Equals(Object^) | (Inherited from Attribute.) |
![]() | GetHashCode() | (Inherited from Attribute.) |
![]() | GetType() | (Inherited from Object.) |
![]() | IsDefaultAttribute() | (Inherited from Attribute.) |
![]() | Match(Object^) | (Inherited from Attribute.) |
![]() | ToString() | (Inherited from Object.) |
| Name | Description | |
|---|---|---|
![]() ![]() | _Attribute::GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) | (Inherited from Attribute.) |
![]() ![]() | _Attribute::GetTypeInfo(UInt32, UInt32, IntPtr) | (Inherited from Attribute.) |
![]() ![]() | _Attribute::GetTypeInfoCount(UInt32) | (Inherited from Attribute.) |
![]() ![]() | _Attribute::Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) | (Inherited from Attribute.) |
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().
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.
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.



