问题
i have been tryign to get current test directory from where tests are running. code that i m using
[TestFixture]
public class ValidatePDF
{
public NUnit.Framework.TestContext TestContext { get; set; }
[SetUp]
public void Init()
{
string t = TestContext.TestDirectory;
}
}
TestContext is always null. i m using Visual Studio 2017 , and NUnit 3 i have tried with MS TextContext but it always return null
public Microsoft.VisualStudio.TestTools.UnitTesting.TestContext TestContext { get; set; }
[Test]
public void GetMetaInfo()
{
string t = TestContext.TestDir;
}
回答1:
Remove the MS TestContext, and use NUnit's built in TestContext. Note that it is a static property, so access the CurrentContext's members.
来源:https://stackoverflow.com/questions/58768812/testcontext-property-is-null