1
votes

vstest.console.exe does not execute my tests.

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

I receive the following output when executing the commandline:

Microsoft (R) Test Execution Command Line Tool Version 11.0.60315.1Copyright (c) Microsoft Corporation. All rights reserved.

NOTE: Tests do get executed when I run 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
            }
        };

However, running mstest on the commandlline results in one of my tests failing even though I cannot reproduce the test failure in VS2012 TestExplorer.

1

1 Answers

0
votes

I needed to surround my test dll path with quotes:

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