Guest User

Untitled

a guest
Jun 22nd, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. private static void RunSelectedTests(List<String> apexClasses)
  2. {
  3. using (var cmdProcess = InitCmdProcess())
  4. {
  5. using (StreamWriter cmdProcessWriter = cmdProcess.StandardInput)
  6. {
  7. var selectedTests = string.Join(",", apexClasses);
  8.  
  9. cmdProcessWriter.WriteLine("sfdx force:apex:test:run -n " + selectedTests);// + " -d \"c:\\my stuff\\logs\"");
  10. }
  11.  
  12. String output;
  13.  
  14. while ((output = cmdProcess.StandardOutput.ReadLine()) != null)
  15. {
  16. if (output.Contains("retrieve test results"))
  17. {
  18. Regex regex = new Regex("([\"'])(?:(?=(\\\\?))\\2.)*?\\1");
  19. Match match = regex.Match(output);
  20. if (match.Success)
  21. {
  22. GetTestResults(match.Value.Trim('"'), apexClasses);
  23. }
  24. }
  25. else
  26. {
  27. Console.Error.WriteLine(output);
  28. }
  29. }
  30. }
  31. }
  32.  
  33. private static Process InitCmdProcess()
  34. {
  35. var cmdProcess = new Process();
  36. cmdProcess.StartInfo.FileName = "cmd.exe";
  37. cmdProcess.StartInfo.RedirectStandardOutput = true;
  38. cmdProcess.StartInfo.RedirectStandardInput = true;
  39. cmdProcess.StartInfo.UseShellExecute = false;
  40. cmdProcess.Start();
  41.  
  42. return cmdProcess;
  43. }
Add Comment
Please, Sign In to add comment