2014-10-20 17 views

답변

2

저는 MbUnit을 사용하지 않았지만, NUnit에서 알고있는 DynamicTestFactory에 가장 가까운 것은 TestCaseSource입니다.

나는 DynamicTestFactory ( here에서)의 예를 발견

[Test, TestCaseSource("SourceList")] 
    public void MyFunctionTest(int i) 
    { 
     Assert.IsTrue(MyFunction(i)); 
    } 

    private static readonly IEnumerable<int> SourceList = new[] { 1, 2, 3, 4, 5 }; 
:

[DynamicTestFactory] 
public IEnumerable<Test> Should_Create_And_Execute_Dynamic_Tests() 
{ 
    IEnumerable<int> list = new[] {1, 2, 3, 4, 5}; 
    foreach (int i in list) 
    { 
     yield return new TestCase(string.Format("Test {0}",i), 
     () => { Assert.IsTrue(MyFunction(i)); }); 
    } 
} 

이 같은 일을 달성하기 위해 NUnit과의이 TestCaseSource (here 참조)를 사용하는 것이 방법입니다