Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static void RunSelectedTests(List<String> apexClasses)
- {
- using (var cmdProcess = InitCmdProcess())
- {
- using (StreamWriter cmdProcessWriter = cmdProcess.StandardInput)
- {
- var selectedTests = string.Join(",", apexClasses);
- cmdProcessWriter.WriteLine("sfdx force:apex:test:run -n " + selectedTests);// + " -d \"c:\\my stuff\\logs\"");
- }
- String output;
- while ((output = cmdProcess.StandardOutput.ReadLine()) != null)
- {
- if (output.Contains("retrieve test results"))
- {
- Regex regex = new Regex("([\"'])(?:(?=(\\\\?))\\2.)*?\\1");
- Match match = regex.Match(output);
- if (match.Success)
- {
- GetTestResults(match.Value.Trim('"'), apexClasses);
- }
- }
- else
- {
- Console.Error.WriteLine(output);
- }
- }
- }
- }
- private static Process InitCmdProcess()
- {
- var cmdProcess = new Process();
- cmdProcess.StartInfo.FileName = "cmd.exe";
- cmdProcess.StartInfo.RedirectStandardOutput = true;
- cmdProcess.StartInfo.RedirectStandardInput = true;
- cmdProcess.StartInfo.UseShellExecute = false;
- cmdProcess.Start();
- return cmdProcess;
- }
Add Comment
Please, Sign In to add comment