void RunTests(TestPlan inTests) { var testsPath = Path.GetTempFileName (); inTests.Save (testsPath); var runner = FindRunner (); if (string.IsNullOrEmpty (runner)) { MessageBox.Show ("Could not find QuickTestRunner.exe"); return; } var info = new System.Diagnostics.ProcessStartInfo { FileName = runner, Arguments = "\"" + testsPath + "\"", RedirectStandardOutput = true, StandardOutputEncoding = Encoding.UTF8, UseShellExecute = false, CreateNoWindow = true, }; var proc = System.Diagnostics.Process.Start (info); var output = proc.StandardOutput.ReadToEnd (); proc.WaitForExit (5000); try { var outTests = TestPlan.Open (new StringReader (output)); foreach (var t in outTests.Tests) { _tests.GetTest (t.Id).RecordResults (t); } _projectRepo.Save (_repoPath); File.Delete (testsPath); } catch (Exception) { } BeginInvoke ((Action)delegate { Progress.Visible = false; if (proc.ExitCode == 0) { OutputTests (); } else { SetStatus (FailStatusIcon, "Execution Failed: " + output); } }); }
void RunRows(IEnumerable<int> rowIndices) { if (_funcElm == null) return; var plan = new TestPlan (); // // Find all the tests that need to run // var nargs = _paramInfos.Count; foreach (var rowIndex in rowIndices) { var row = Grid.Rows[rowIndex]; if (row.Tag == null) { var rt = new Test { Id = Guid.NewGuid (), }; _tests.Tests.Add (rt); row.Tag = rt; } var t = ParseRow (rowIndex); plan.Tests.Add (t); } if (plan.Tests.Count == 0) return; // // Get the extra info needed by the test plan // var project = _funcElm.ProjectItem.ContainingProject; plan.AssemblyPath = GetAssemblyPath (project); try { var references = ((dynamic)project.Object).References; foreach (var item in references) { plan.References.Add (new TestAssemblyReference { Name = item.Name, Version = item.Version, Culture = item.Culture, PublicKeyToken = item.PublicKeyToken.ToString ().ToLowerInvariant (), Path = item.Path, StrongName = item.StrongName, }); } } catch (Exception) { } // // Run it // Progress.Visible = true; SetStatus (InfoStatusIcon, "Test run in progress"); ThreadPool.QueueUserWorkItem (delegate { RunTests (plan); }); }