1

类是否有等效的TestPropertyAttribute可用?我想用一个属性标记一堆测试,而不必标记每个测试。

提前致谢。

4

2 回答 2

2

Unfortunately there is none. We don't have a TestProperty equivalent at the class level.

于 2012-12-11T04:15:19.093 回答
1

刚刚发现这个使用了TestProperty类,在初始化时用来设置一个类成员。它设置了一个默认值,你用不同的设置标记测试[TestProperty("thing", "non-default")]

[ClassInitialize()]
public void InitializeClass(TestContext testContext)
{
    // Changed by the [TestProperty("thing", "non-default")]
    if (TestContext.Properties.Contains("thing"))
        _thing = TestContext.Properties["thing"] as string;
    else
        _thing = "default";
}

进一步的解释在这里

于 2013-09-04T09:45:36.453 回答