Ejemplo n.º 1
0
        public TestExecutionResults Parse(string output, int exitCode)
        {
            string pattern = "(?<run>.+) run, (?<passed>.+) passed, (?<failed>.+) failed (.*), (?<inconclusive>.+) inconclusive, (?<skipped>.+) skipped";
            Regex regex = new Regex(pattern, RegexOptions.IgnorePatternWhitespace | RegexOptions.IgnoreCase);

            Match m = regex.Match(output);
            if (m.Success)
            {
                TestExecutionResults results = new TestExecutionResults();
                results.Run = Convert.ToInt32(m.Groups["run"].Value.Trim());
                results.Passed = Convert.ToInt32(m.Groups["passed"].Value.Trim());
                results.Failed = Convert.ToInt32(m.Groups["failed"].Value.Trim());
                results.Skipped = Convert.ToInt32(m.Groups["inconclusive"].Value.Trim()) + Convert.ToInt32(m.Groups["skipped"].Value.Trim());

                results.ExecutionResult = exitCode == 0 ? TestExecutionResult.Passed : TestExecutionResult.Failed;
                results.Output = output;
                return results;
            }

            return null;
        }
Ejemplo n.º 2
0
        private void OutputResults(TestExecutionResults testExecutionResults)
        {
            Console.ResetColor();
            switch (testExecutionResults.ExecutionResult)
            {
                case TestExecutionResult.Passed:
                    Console.BackgroundColor = ConsoleColor.Green;
                    Console.ForegroundColor = ConsoleColor.Black;
                    break;
                case TestExecutionResult.Failed:
                    Console.BackgroundColor = ConsoleColor.Red;
                    Console.ForegroundColor = ConsoleColor.Black;
                    break;
            }

            Console.Write("Result of execution: " + testExecutionResults.ExecutionResult);
            Console.Write(" Run: " + testExecutionResults.Run);
            Console.Write(" Passed: " + testExecutionResults.Passed);
            Console.Write(" Failed: " + testExecutionResults.Failed);
            Console.Write(" Skipped: " + testExecutionResults.Skipped);
            Console.WriteLine();

            Console.ResetColor();
        }