2011-09-19 84 views
1

是否有类似于Sequential Attribute的东西,我可以将其放在课程本身上。 并且在类级别上使用顺序变量,而不是在特定的测试级别上,因为它与Sequential Attribute一起使用。班级级别nunit的顺序属性

我只需要运行与我们使用的变量组合相关的TestFixtureSetUp。

感谢

回答

2

如何Parameterized Test Fixtures?您可以在您的TestFixture c'tor中传递参数列表,例如:

[TestFixture("hello", "hello", "goodbye")] 
[TestFixture("zip", "zip")] 
[TestFixture(42, 42, 99)] 
public class ParameterizedTestFixture 
{ 
    private string eq1; 
    private string eq2; 
    private string neq; 

    public ParameterizedTestFixture(string eq1, string eq2, string neq) 
    { 
     this.eq1 = eq1; 
     this.eq2 = eq2; 
     this.neq = neq; 
    } 

    [Test] 
    public void TestEquality() 
    { 
     Assert.AreEqual(eq1, eq2); 
     if (eq1 != null && eq2 != null) 
      Assert.AreEqual(eq1.GetHashCode(), eq2.GetHashCode()); 
    } 
}