如何在mstest / .NET Core 1.1单元测试中获取测试部署目录?
我正在尝试在.NET Core 1.1中重新创建基于mstest和.NET Framework的测试。以前有代码通过使用公开的测试上下文属性检索测试部署目录,如下面的代码块。但是使用.NET Core,似乎TestContext对象不再具有TestDeploymentDir属性。
public TestContext TestContext
{
get
{
return this.testContextInstance;
}
set
{
this.testContextInstance = value;
}
}
...
// This worked in .NET Framework, but TestDeploymentDir is not available in .NET Core.
// What can I use as a replacement?
string deploymentPath = this.TestContext.TestDeploymentDir
...
我看到TestDeploymentDir已弃用,但其替换的DeploymentDirectory也不可用。 (参考:https://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.unittesting.testcontext.deploymentdirectory.aspx)