【发布时间】:2013-05-05 06:58:07
【问题描述】:
使用 Xunit,如何获取当前运行测试的名称?
public class TestWithCommonSetupAndTearDown : IDisposable
{
public TestWithCommonSetupAndTearDown ()
{
var nameOfRunningTest = "TODO";
Console.WriteLine ("Setup for test '{0}.'", nameOfRunningTest);
}
[Fact]
public void Blub ()
{
}
public void Dispose ()
{
var nameOfRunningTest = "TODO";
Console.WriteLine ("TearDown for test '{0}.'", nameOfRunningTest);
}
}
编辑:
特别是,我正在寻找 NUnits TestContext.CurrentContext.Test.Name 属性的替代品。
【问题讨论】: