private static void RunTestCore(bool debug) { var lastBuildStatusArgs = new LastBuildStatusArgs(); OnQueryLastBuildStatus(lastBuildStatusArgs); try { DTE.WriteToOutput("Building EasyTest/Debug Configuration"); if (DTE.Solution.BuildSolution()) { var activeFileName = DTE.ActiveDocument.FullName; var testLogPath = Path.Combine(Path.GetDirectoryName(activeFileName) + "", "Testslog.xml"); if (File.Exists(testLogPath)) { File.Delete(testLogPath); } var debugSwitch = WriteToOutput(debug, activeFileName); var testExecutorPath = GetTestExecutorPath(); if (!File.Exists(testExecutorPath)) { throw new FileNotFoundException( "Use plugin options to assign a valid path for the standalond TestExecutor. Or leave it blank for auto detection."); } var processStartInfo = new ProcessStartInfo(testExecutorPath) { Arguments = $@"""{activeFileName}""{debugSwitch}", UseShellExecute = debug, RedirectStandardOutput = !debug, CreateNoWindow = !debug }; var process = System.Diagnostics.Process.Start(processStartInfo); Debug.Assert(process != null, "process != null"); process.WaitForExit(); if (File.Exists(testLogPath)) { var document = XDocument.Load(File.OpenRead(testLogPath)); var errorElement = document.Descendants().FirstOrDefault(element => element.Name.LocalName == "Error"); if (errorElement != null) { var messageElement = errorElement.Descendants("Message").First(); DTE.WriteToOutput(messageElement.Value); } else { DTE.WriteToOutput("EasyTest Passed!"); } } } else { DTE.WriteToOutput("EasyTest build failed"); } } catch (Exception e) { DTE.WriteToOutput(e.ToString()); } }
protected static void OnQueryLastBuildStatus(LastBuildStatusArgs e) { QueryLastBuildStatus?.Invoke(null, e); }