VSTest.Console.Exe 不执行测试

VSTest.Console.Exe does not execute tests

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) Test Execution Command Line Tool Version 11.0.60315.1Copyright (c) Microsoft Corporation. All rights reserved.

注意: 当我 运行 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 中重现测试失败。

我需要用引号将我的测试 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
    }
};