public VSTestResult(ProcessRunResult processRunResult, string outcome, VSTestResultCounters counters, IReadOnlyList <string> runErrors = null, IReadOnlyList <string> runWarnings = null)
 {
     ProcessRunResult = processRunResult;
     Outcome          = outcome;
     Counters         = counters;
     RunErrors        = runErrors ?? Array.Empty <string>();
     RunWarnings      = runWarnings ?? Array.Empty <string>();
 }
Esempio n. 2
0
 public VSTestResult(ProcessRunResult processRunResult)
 {
     ProcessRunResult = processRunResult;
     Outcome          = "";
     Counters         = VSTestResultCounters.CreateEmptyCounters();
     RunErrors        = Array.Empty <string>();
     RunWarnings      = Array.Empty <string>();
 }
        private static string BuildMessage(ProcessRunResult result)
        {
            var builder = new StringBuilder();

            builder.Append("Process ‘").Append(result.ProcessName);
            builder.Append("’ exited with code ").Append(result.ExitCode).Append('.');
            builder.AppendLine().Append("Executable: ").Append(result.FileName);

            if (!string.IsNullOrWhiteSpace(result.Arguments))
            {
                builder.AppendLine().Append("Arguments: ").Append(result.Arguments);
            }

            var hasStdErr = !string.IsNullOrWhiteSpace(result.StdErr);

            if (hasStdErr || !string.IsNullOrWhiteSpace(result.StdOut))
            {
                builder.AppendLine().Append(hasStdErr ? "Stderr:" : "Stdout:");
                builder.AppendLine().Append(hasStdErr ? result.StdErr : result.StdOut);
            }

            return(builder.ToString());
        }
        public static VSTestResult Load(ProcessRunResult processRunResult, string trxFilePath)
        {
            var trx = XDocument.Load(trxFilePath);

            var ns = (XNamespace)"http://microsoft.com/schemas/VisualStudio/TeamTest/2010";

            var resultSummary = trx.Root.Element(ns + "ResultSummary");
            var counters      = resultSummary.Element(ns + "Counters");

            var runInfos = resultSummary.Element(ns + "RunInfos")?.Elements().Select(runInfo => (
                                                                                         Outcome: runInfo.Attribute("outcome")?.Value,
                                                                                         Text: runInfo.Element(ns + "Text")?.Value ?? string.Empty));

            return(new VSTestResult(
                       processRunResult,
                       (string)resultSummary.Attribute("outcome"),
                       new VSTestResultCounters(
                           (int)counters.Attribute("total"),
                           (int)counters.Attribute("executed"),
                           (int)counters.Attribute("passed"),
                           (int)counters.Attribute("failed"),
                           (int)counters.Attribute("error"),
                           (int)counters.Attribute("timeout"),
                           (int)counters.Attribute("aborted"),
                           (int)counters.Attribute("inconclusive"),
                           (int)counters.Attribute("passedButRunAborted"),
                           (int)counters.Attribute("notRunnable"),
                           (int)counters.Attribute("notExecuted"),
                           (int)counters.Attribute("disconnected"),
                           (int)counters.Attribute("warning"),
                           (int)counters.Attribute("completed"),
                           (int)counters.Attribute("inProgress"),
                           (int)counters.Attribute("pending")),
                       runErrors: runInfos?.Where(i => i.Outcome == "Error").Select(i => i.Text).ToList(),
                       runWarnings: runInfos?.Where(i => i.Outcome == "Warning").Select(i => i.Text).ToList()));
        }
 public ProcessErrorException(ProcessRunResult result)
     : base(BuildMessage(result))
 {
     Result = result;
 }