2017-09-25 11 views

答えて

2

NUnit 3.xでは、TestContext.CurrentContext.Test.Nameを使用してください。 Testには、MethodNameFullNameのような他のプロパティも必要です。

[TestFixture] 
public class TestNameInSetup 
{ 
    [SetUp] 
    public void SetUp() 
    { 
     var testName = TestContext.CurrentContext.Test.Name; 
     TestContext.WriteLine($"SetUp for {testName}"); 
    } 

    [Test] 
    public void NamedTest() 
    { 
     var testName = TestContext.CurrentContext.Test.Name; 
     TestContext.WriteLine($"Running test {testName}"); 
    } 
} 
関連する問題