Пример #1
0
        public void ShouldReportPassFailSkipCounts()
        {
            using (var console = new RedirectedConsole())
            {
                var listener = new ConsoleListener();
                var assembly = typeof(ConsoleListener).Assembly;
                var version = assembly.GetName().Version;

                var assemblyResult = new AssemblyResult(assembly.Location);
                var conventionResult = new ConventionResult("Fake Convention");
                var classResult = new ClassResult("Fake Class");
                assemblyResult.Add(conventionResult);
                conventionResult.Add(classResult);
                classResult.Add(CaseResult.Passed("A", TimeSpan.Zero));
                classResult.Add(CaseResult.Failed("B", TimeSpan.Zero, "Message", "Stack Trace", "Exception Type"));
                classResult.Add(CaseResult.Failed("C", TimeSpan.Zero, "Message", "Stack Trace", "Exception Type"));
                classResult.Add(CaseResult.Skipped("D", "Reason"));
                classResult.Add(CaseResult.Skipped("E", "Reason"));
                classResult.Add(CaseResult.Skipped("F", "Reason"));

                listener.AssemblyCompleted(assembly, assemblyResult);

                console.Lines().ShouldEqual("1 passed, 2 failed, 3 skipped, took 0.00 seconds (Fixie " + version + ").");
            }
        }
Пример #2
0
        public void ShouldReportPassFailSkipCounts()
        {
            using (var console = new RedirectedConsole())
            {
                var listener = new ConsoleListener();
                var assembly = typeof(ConsoleListener).Assembly;
                var version = assembly.GetName().Version;

                var assemblyResult = new AssemblyResult(assembly.Location);
                var conventionResult = new ConventionResult("Fake Convention");
                var classResult = new ClassResult("Fake Class");
                assemblyResult.Add(conventionResult);
                conventionResult.Add(classResult);
                classResult.Add(CaseResult.Passed("A", TimeSpan.Zero));
                classResult.Add(CaseResult.Failed("B", TimeSpan.Zero, new ExceptionInfo(new Exception(), new AssertionLibraryFilter())));
                classResult.Add(CaseResult.Failed("C", TimeSpan.Zero, new ExceptionInfo(new Exception(), new AssertionLibraryFilter())));
                classResult.Add(CaseResult.Skipped("D", "Reason"));
                classResult.Add(CaseResult.Skipped("E", "Reason"));
                classResult.Add(CaseResult.Skipped("F", "Reason"));

                listener.AssemblyCompleted(assembly, assemblyResult);

                console.Lines().ShouldEqual(string.Format("1 passed, 2 failed, 3 skipped, took {0} seconds (Fixie {1}).",
                                                          0.ToString("N2", CultureInfo.CurrentCulture),
                                                          version));
            }
        }
Пример #3
0
 static XElement Convention(ConventionResult conventionResult)
 {
     return new XElement("test-suite",
         new XAttribute("success", conventionResult.Failed == 0),
         new XAttribute("name", conventionResult.Name),
         new XAttribute("time", Seconds(conventionResult.Duration)),
         new XElement("results", conventionResult.ClassResults.Select(Class)));
 }
Пример #4
0
        public ConventionResult Run(Convention convention, Listener listener, params Type[] candidateTypes)
        {
            var executionPlan = new ExecutionPlan(convention);
            var conventionResult = new ConventionResult(convention.GetType().FullName);

            foreach (var testClass in convention.Classes.Filter(candidateTypes))
            {
                var classResult = new ClassResult(testClass.FullName);

                var methods = convention.Methods.Filter(testClass);

                var cases = methods.SelectMany(method => CasesForMethod(convention, method)).ToArray();
                var casesBySkipState = cases.ToLookup(convention.CaseExecution.SkipPredicate);
                var casesToSkip = casesBySkipState[true];
                var casesToExecute = casesBySkipState[false];
                foreach (var @case in casesToSkip)
                {
                    var skipResult = new SkipResult(@case, convention.CaseExecution.SkipReasonProvider(@case));
                    listener.CaseSkipped(skipResult);
                    classResult.Add(CaseResult.Skipped(skipResult.Case.Name, skipResult.Reason));
                }

                var caseExecutions = casesToExecute.Select(@case => new CaseExecution(@case)).ToArray();
                if (caseExecutions.Any())
                {
                    convention.ClassExecution.OrderCases(caseExecutions);

                    var classExecution = new ClassExecution(executionPlan, testClass, caseExecutions);
                    executionPlan.Execute(classExecution);

                    foreach (var caseExecution in caseExecutions)
                    {
                        if (caseExecution.Exceptions.Any())
                        {
                            var failResult = new FailResult(caseExecution, convention.HideExceptionDetails);
                            listener.CaseFailed(failResult);
                            classResult.Add(CaseResult.Failed(failResult.Case.Name, failResult.Duration, failResult.ExceptionSummary));
                        }
                        else
                        {
                            var passResult = new PassResult(caseExecution);
                            listener.CasePassed(passResult);
                            classResult.Add(CaseResult.Passed(passResult.Case.Name, passResult.Duration));
                        }
                    }

                }

                conventionResult.Add(classResult);
            }

            return conventionResult;
        }
Пример #5
0
        public ConventionResult Execute(Listener listener, params Type[] candidateTypes)
        {
            var conventionResult = new ConventionResult(GetType().FullName);

            foreach (var testClass in Classes.Filter(candidateTypes))
            {
                var classResult = new ClassResult(testClass.FullName);

                var methods = Methods.Filter(testClass);

                var cases = methods.SelectMany(method => CasesForMethod(testClass, method)).ToArray();
                var casesBySkipState = cases.ToLookup(CaseExecution.SkipPredicate);
                var casesToSkip = casesBySkipState[true];
                var casesToExecute = casesBySkipState[false];
                foreach (var @case in casesToSkip)
                {
                    listener.CaseSkipped(@case);
                    classResult.Add(CaseResult.Skipped(@case.Name, CaseExecution.SkipReasonProvider(@case)));
                }

                var caseExecutions = casesToExecute.Select(@case => new CaseExecution(@case)).ToArray();
                if (caseExecutions.Any())
                {
                    ClassExecution.Behavior.Execute(testClass, this, caseExecutions);

                    foreach (var caseExecution in caseExecutions)
                    {
                        if (caseExecution.Exceptions.Any())
                        {
                            var failResult = new FailResult(caseExecution);
                            listener.CaseFailed(failResult);
                            classResult.Add(CaseResult.Failed(failResult.Case.Name, failResult.Duration, failResult.PrimaryExceptionMessage(), failResult.CompoundStackTrace(), failResult.PrimaryExceptionTypeName()));
                        }
                        else
                        {
                            var passResult = new PassResult(caseExecution);
                            listener.CasePassed(passResult);
                            classResult.Add(CaseResult.Passed(passResult.Case.Name, passResult.Duration));
                        }
                    }

                }

                conventionResult.Add(classResult);
            }

            return conventionResult;
        }
Пример #6
0
        static XElement TestSuiteElement(ConventionResult conventionResult)
        {
            var suite = new XElement("test-suite",
                new XAttribute("success", conventionResult.Failed == 0),
                new XAttribute("name", conventionResult.Name),
                new XAttribute("time", conventionResult.Duration.TotalSeconds.ToString("0.000")));

            var results = new XElement("results");

            suite.Add(results);

            foreach (var classResult in conventionResult.ClassResults)
                results.Add(TestSuiteElement(classResult));

            return suite;
        }
Пример #7
0
 public void Add(ConventionResult classResult)
 {
     conventionResults.Add(classResult);
 }
Пример #8
0
 public void Add(ConventionResult classResult)
 {
     conventionResults.Add(classResult);
 }