C# 从StaticTestFactory创建时,Teardown中的TestOutput状态不正确
使用MbUnit,我使用几个StaticTestFactory方法创建测试,每个方法都有相应的测试设置和拆卸方法。要求将测试结果记录到外部系统,尤其是失败的系统 但是,我无法使用TestContext.CurrentContext.Output.status获得正确的测试结果状态。使用下面的代码,您将看到测试失败,但即使Gallio Icarus和Echo都显示测试失败,Output.status始终从FactoryAssignedTeardDownMethod返回为“通过” 正在寻找任何解决方法或修复方法,以在此场景中获得正确的结果C# 从StaticTestFactory创建时,Teardown中的TestOutput状态不正确,c#,unit-testing,mbunit,gallio,C#,Unit Testing,Mbunit,Gallio,使用MbUnit,我使用几个StaticTestFactory方法创建测试,每个方法都有相应的测试设置和拆卸方法。要求将测试结果记录到外部系统,尤其是失败的系统 但是,我无法使用TestContext.CurrentContext.Output.status获得正确的测试结果状态。使用下面的代码,您将看到测试失败,但即使Gallio Icarus和Echo都显示测试失败,Output.status始终从FactoryAssignedTeardDownMethod返回为“通过” 正在寻找任何解决方
public class FactoryTest
{
[StaticTestFactory]
public static IEnumerable<Test> CreateStaticTests()
{
var testcase = new TestCase("simpletest" , () =>
{
Assert.Fail("staticfactory created test failed.");
});
testcase.TearDown = FactoryAssignedTearDownMethod;
yield return testcase;
}
public static void FactoryAssignedTearDownMethod()
{
//outcome value is always 'Passed', even when test fails
TestLog.WriteLine("Test Outcome Status from factory assigned method: " + TestContext.CurrentContext.Outcome.Status);
}
}
公共类FactoryTest
{
[静态测试工厂]
公共静态IEnumerable CreateStaticTests()
{
var testcase=newtestcase(“simpletest”,()=>
{
Assert.Fail(“staticfactory创建的测试失败”);
});
testcase.TearDown=FactoryAssignedTeardown方法;
收益率测试用例;
}
公共静态void factoryAssignedTeardDownMethod()
{
//即使测试失败,结果值也始终“通过”
WriteLine(“工厂指定方法的测试结果状态:“+TestContext.CurrentContext.Output.Status”);
}
}
我通过编写GallioTestRunnerExtension来解决这个问题。通过处理TestStepFinished
事件,我可以为使用StaticTestFactory创建的所有测试获得正确的测试结果