【发布时间】:2014-02-11 03:29:37
【问题描述】:
我是编程新手,这可能是一个非常基本的问题,但我想知道 [TestMethod] 和 [CodedUITest] 等放在 [括号] 中的哪些项目被调用,以及它们在 .NET 中的作用。为什么这些方法都是这样写的?
谢谢
【问题讨论】:
标签: c# .net coded-ui-tests
我是编程新手,这可能是一个非常基本的问题,但我想知道 [TestMethod] 和 [CodedUITest] 等放在 [括号] 中的哪些项目被调用,以及它们在 .NET 中的作用。为什么这些方法都是这样写的?
谢谢
【问题讨论】:
标签: c# .net coded-ui-tests
那些被称为Attributes。它们为您的代码元数据提供 IDE 可用于执行诸如了解哪些方法是单元测试、如何序列化类或在智能提示提示中首先显示什么等事情。
【讨论】:
它们是属性
Attributes can be placed on most any declaration, though a
specific attribute might restrict the types of declarations on which it is valid.
In C#, you specify an attribute by placing the name of the attribute, enclosed in square brackets ([]), above
the declaration of the entity to which it applies. In Visual Basic, an attribute
is enclosed in angle brackets (< >). It must appear immediately before the element to
它被应用, 在同一行。
【讨论】: