mbunit で StaticTestFactory を使用してテストを生成する場合、テスト スイートは、前のテストが成功した場合にのみ実行する必要があります。以下のコード サンプルでは、依存するテストが失敗した場合でも、テスト Factory_ShouldNotRun_Test が実行されます。
DependsOn 属性は単純なテストでは機能しますが、StaticTestFactory では機能しません。
何か案は?前もって感謝します。
public class Dependency_Test
{
[Test]
public void DependsOnMe_Test()
{
Assert.Fail("I fail and dependent tests should be skipped");
}
[Test]
[DependsOn("DependsOnMe_Test")]
public void Simple_Test_ShouldNotRun()
{
Assert.Fail("Simple test should not run");
}
[StaticTestFactory]
[DependsOn("DependsOnMe_Test")]
public static IEnumerable<Test> Factory_ShouldNotRun_Test()
{
var testCase = new TestCase("Factory_ShouldNotRun_Test", () =>
{
Assert.Fail("Factory test should not run");
});
yield return testCase;
}
}