TestClassAttribute 类

更新:2007 年 11 月

用于标识包含测试方法的类。此类不能被继承。

命名空间:  Microsoft.VisualStudio.TestTools.UnitTesting
程序集:  Microsoft.VisualStudio.SmartDevice.UnitTestFramework(在 Microsoft.VisualStudio.SmartDevice.UnitTestFramework.dll 中)

语法

声明
<AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple := False)> _
Public NotInheritable Class TestClassAttribute _
    Inherits Attribute
用法
Dim instance As TestClassAttribute
[AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple = false)]
public sealed class TestClassAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Class, AllowMultiple = false)]
public ref class TestClassAttribute sealed : public Attribute
public final class TestClassAttribute extends Attribute

备注

如果用 TestMethodAttribute 标记的测试方法所属的类没有用 TestClassAttribute 标记,则这些测试方法不可用。如果没有 TestClassAttribute,则测试类无效。

可以在类上指定此属性。只能将此属性的一个实例应用于一个类。

默认情况下,此属性用于生成的代码中。

有关如何使用属性的更多信息,请参见 利用属性扩展元数据

继承层次结构

System.Object
  System.Attribute
    Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute

线程安全

此类型的任何公共 static(在 Visual Basic 中为 Shared) 成员都是线程安全的。但不保证所有实例成员都是线程安全的。

另请参见

参考

TestClassAttribute 成员

Microsoft.VisualStudio.TestTools.UnitTesting 命名空间