vstest.console.exe不会执行我的测试。
var testProcess = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = @"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe",
Arguments = _testDllPath,
UseShellExecute = false,
RedirectStandardOutput = true,
CreateNoWindow = true
}
};
执行命令行时收到以下输出:
Microsoft(R)测试执行命令行工具版本11.0.60315.1版权所有(c)Microsoft Corporation。保留所有权利。
注意:当我运行MSTest时,测试会执行:
var testProcess = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = @"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\mstest.exe",
Arguments = string.Format(@"/testcontainer:""{0}"" /resultsfile:""{1}""", _testDllPath, _resultsDirectoryPath),
UseShellExecute = false,
RedirectStandardOutput = true,
CreateNoWindow = true
}
};
但是,在commandlline上运行mstest导致我的一个测试失败,即使我无法在VS2012 TestExplorer中重现测试失败。
答案 0 :(得分:0)
我需要用引号括起我的测试dll路径:
var testProcess = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = @"C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe",
Arguments = _testDllPath.Replace(_testDllPath, '"' + _testDllPath + '"'),
UseShellExecute = false,
RedirectStandardOutput = true,
CreateNoWindow = true
}
};