1

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
            }
        };

但是,在命令行上运行 mstest 会导致我的一项测试失败,即使我无法在 VS2012 TestExplorer 中重现测试失败。

4

1 回答 1

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
    }
};
于 2015-02-13T13:07:40.430 回答