public void Run(string testExecutable, string testName, ITestOutput output) { var commandLineGenerator = new CommandLineGenerator(); var options = TestRunnerOptions.FromDteProperties(_dte.Properties["BoostTest", "TestRunner"]); var testRunnerProcess = new ChildProcess(commandLineGenerator.Generate(testExecutable, testName, options)); testRunnerProcess.StartSuspended(); var process = _dte.Debugger.LocalProcesses.Cast<EnvDTE.Process>().SingleOrDefault(p => p.ProcessID == testRunnerProcess.Pid); if (process == null) { throw new InvalidOperationException("Couldn't find the process : " + testExecutable); } process.Attach(); testRunnerProcess.Resume() .ContinueWith( x => { if (x.IsCompleted) { output.Clear(); output.OutputString(DateTime.Now.ToLongTimeString() + " : Test (Debug) : " + testName + "\n"); output.OutputString(x.Result); } }); }
public void CanExecuteInASuspendedChildProcessAndRedirectOutputToString() { string command_line = "sample_test -t complex_numbers/add_complex_numbers"; var suspendedProcessTask = new ChildProcess(command_line); string result = string.Empty; suspendedProcessTask.StartSuspended(); suspendedProcessTask.Resume() .ContinueWith( (task) => { result = task.Result; }).Wait(); const string expected_result = "Running 1 test case...\r\n\r\n*** No errors detected\r\n"; Assert.AreEqual(expected_result, result); }