コード例 #1
0
        public void RunTests(IEnumerable <TestDetails> tests, TestAssembly assembly, string runnerPath, IDebugAttacher debuggerAttacher)
        {
            Dictionary <string, TestDetails> testHashTable = new Dictionary <string, TestDetails>();

            ProcessStartInfo testRunnerStartParameters = new ProcessStartInfo()
            {
                FileName = runnerPath,
                RedirectStandardOutput = true,
                UseShellExecute        = false,
                RedirectStandardInput  = true,
                RedirectStandardError  = true,
                CreateNoWindow         = true,
                WindowStyle            = ProcessWindowStyle.Hidden
            };

            using (var testRunnerProcess = new Process())
            {
                testRunnerProcess.StartInfo           = testRunnerStartParameters;
                testRunnerProcess.OutputDataReceived += new DataReceivedEventHandler(testRunnerProcess_OutputDataReceived);
                testRunnerProcess.Start();

                if (debuggerAttacher != null)
                {
                    debuggerAttacher.AttachToProcess(testRunnerProcess.Id);
                }

                testRunnerProcess.BeginOutputReadLine();

                ProcessTests(assembly, tests, testRunnerProcess.StandardInput);

                //var runnerResult = testRunnerProcess.StandardOutput.ReadToEnd();
                // ProcessTestResults("", testHashTable);

                _testWaitHandle = new AutoResetEvent(false);
                _testWaitHandle.WaitOne();
            }
        }