是否有相当于一个类可用的TestPropertyAttribute?我想用一个属性标记一堆测试,而不必标记每个测试。什么是TestPropertyAttribute的等价类可用于类,而不是方法
在此先感谢。
是否有相当于一个类可用的TestPropertyAttribute?我想用一个属性标记一堆测试,而不必标记每个测试。什么是TestPropertyAttribute的等价类可用于类,而不是方法
在此先感谢。
不幸的是没有。我们在课堂上没有相应的TestProperty。
刚刚发现此初始化中使用的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";
}
进一步的解释是here。