【问题标题】:VSTest.Console.Exe does not execute testsVSTest.Console.Exe 不执行测试
【发布时间】:2015-02-13 12:49:08
【问题描述】:

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 中重现测试失败。

【问题讨论】:

    标签: visual-studio-2012 mstest unit-testing vstest


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-30
      • 2016-07-20
      • 1970-01-01
      • 1970-01-01
      • 2021-04-21
      相关资源
      最近更新 更多