Esempio n. 1
0
        public string FailureSummary( ContextCollection contexts )
        {
            if( contexts.Failures().Count() == 0 ) return "";

            var summary = Environment.NewLine + "**** FAILURES ****" + Environment.NewLine;

            contexts.Failures().Do( f => summary += WriteFailure( f ) );

            return summary;
        }
Esempio n. 2
0
        public string FailureSummary(ContextCollection contexts)
        {
            if (contexts.Failures().Count() == 0) return "";

            var summary = "\n" + "**** FAILURES ****" + "\n";

            contexts.Failures().Do(f => summary += WriteFailure(f));

            return summary;
        }
Esempio n. 3
0
        public string FailureSummary(ContextCollection contexts)
        {
            if (contexts.Failures().Count() == 0)
            {
                return("");
            }

            var summary = "\n" + "**** FAILURES ****" + "\n";

            contexts.Failures().Where(t => ExamplesToProcess.Count == 0 || ExamplesToProcess.Contains(GetSpecName(t))).Do(f => summary += WriteFailure(f));
            return(summary);
        }
Esempio n. 4
0
        public string FailureSummary(ContextCollection contexts)
        {
            if (contexts.Failures().Count() == 0)
            {
                return("");
            }

            var summary = "\n" + "**** FAILURES ****" + "\n";

            contexts.Failures().Do(f => summary += WriteFailure(f));

            return(summary);
        }
Esempio n. 5
0
        public string FailureSummary(ContextCollection contexts)
        {
            if (contexts.Failures().Count() == 0)
            {
                return("");
            }

            var summary = Environment.NewLine + "**** FAILURES ****" + Environment.NewLine;

            contexts.Failures().Do(f => summary += WriteFailure(f));

            return(summary);
        }
Esempio n. 6
0
            void IFormatter.Write(ContextCollection contexts)
            {
                //Not calling base here lets us get rid of its noisy stack trace output so it does not obscure our thrown exceptions stacktrace.
                Console.WriteLine();
                if (contexts.Failures().Any())
                {
                    WriteNoticably("SUMMARY");
                    Console.WriteLine(base.Summary(contexts));

                    int currentFailure = 0;
                    foreach (var failure in contexts.Failures())
                    {
                        Console.WriteLine();
                        Console.Write("#################################  FAILURE {0} #################################", ++currentFailure);

                        var current         = failure.Context;
                        var relatedContexts = new List <Context>()
                        {
                            current
                        };
                        while (null != (current = current.Parent))
                        {
                            relatedContexts.Add(current);
                        }

                        var levels = relatedContexts.Select(me => me.Name)
                                     .Reverse()
                                     .Skip(1)
                                     .Concat(new string[] { failure.Spec + " - " + failure.Exception.Message });

                        var message = levels
                                      .Select((name, level) => "\t".Times(level) + name)
                                      .Aggregate(Environment.NewLine + "at: ", (agg, curr) => agg + curr + Environment.NewLine);

                        Console.WriteLine(message);

                        Console.WriteLine(base.WriteFailure(failure));
                    }
                }



                Console.WriteLine();
                WriteNoticably("END OF NSPEC RESULTS");
                Console.WriteLine();
            }
Esempio n. 7
0
 public string Summary(ContextCollection contexts)
 {
     return("{0} Examples, {1} Failed, {2} Pending".With(
                contexts.Examples().Count(),
                contexts.Failures().Count(),
                contexts.Pendings().Count()
                ));
 }
Esempio n. 8
0
 public string Summary( ContextCollection contexts )
 {
     return "{0} Examples, {1} Failed, {2} Pending".With(
         contexts.Examples().Count(),
         contexts.Failures().Count(),
         contexts.Pendings().Count()
     );
 }
Esempio n. 9
0
        public void Write(ContextCollection contexts)
        {
            var examples = contexts.Examples().Count();
            var failures = contexts.Failures().Count();

            _sessionResults.SessionRunState = GetSessionRunState(examples, failures);

            contexts.Examples().Each(e => _sessionResults.TestResults.Add(e.ToTestResult()));
        }
Esempio n. 10
0
            void IFormatter.Write(ContextCollection contexts)
            {
                //Not calling base here lets us get rid of its noisy stack trace output so it does not obscure our thrown exceptions stacktrace.
                Console.WriteLine();
                if(contexts.Failures().Any())
                {
                    WriteNoticably("SUMMARY");                    
                    Console.WriteLine(base.Summary(contexts));

                    int currentFailure = 0;
                    foreach (var failure in contexts.Failures())
                    {
                        Console.WriteLine();
                        Console.Write("#################################  FAILURE {0} #################################", ++currentFailure);

                        var current = failure.Context;
                        var relatedContexts = new List<Context>() { current };
                        while (null != (current = current.Parent))
                        {
                            relatedContexts.Add(current);
                        }

                        var levels = relatedContexts.Select(me => me.Name)
                                                    .Reverse()
                                                    .Skip(1)
                                                    .Concat(new string[] { failure.Spec + " - " + failure.Exception.Message });

                        var message = levels
                            .Select((name, level) => "\t".Times(level) + name)
                            .Aggregate(Environment.NewLine + "at: ", (agg, curr) => agg + curr + Environment.NewLine);

                        Console.WriteLine(message);

                        Console.WriteLine(base.WriteFailure(failure));                        
                    }
                }

                

                Console.WriteLine();
                WriteNoticably("END OF NSPEC RESULTS");                
                Console.WriteLine();
            }
Esempio n. 11
0
        public string Summary(ContextCollection contexts)
        {
            var summary = "{0} Examples, {1} Failed, {2} Pending".With(
                contexts.Examples().Count(),
                contexts.Failures().Count(),
                contexts.Pendings().Count()
                );

            if (contexts.AnyTaggedWithFocus())
            {
                summary += Environment.NewLine + Environment.NewLine + @"NSpec found context/examples tagged with ""focus"" and only ran those.";
            }

            return(summary);
        }
Esempio n. 12
0
        public string Summary(ContextCollection contexts)
        {
            var summary = "{0} Examples, {1} Failed, {2} Pending".With(
                contexts.Examples().Count(),
                contexts.Failures().Count(),
                contexts.Pendings().Count()
                );

            if (contexts.AnyTaggedWithFocus())
            {
                summary += Environment.NewLine + Environment.NewLine + @"NSpec found context/examples tagged with ""focus"" and only ran those.";
            }

            return summary;
        }
Esempio n. 13
0
        public string Summary(ContextCollection contexts)
        {
            var condition = new Func <ExampleBase, bool>(t => ExamplesToProcess.Count == 0 || ExamplesToProcess.Contains(GetSpecName(t)));

            var summary = "{0} Examples, {1} Failed, {2} Pending".With(
                contexts.Examples().Where(condition).Count(),
                contexts.Failures().Where(condition).Count(),
                contexts.Pendings().Where(condition).Count()
                );

            if (contexts.AnyTaggedWithFocus())
            {
                summary += "\n" + "\n" + @"NSpec found context/examples tagged with ""focus"" and only ran those.";
            }

            return(summary);
        }
Esempio n. 14
0
        public void Write(ContextCollection contexts)
        {
            StringBuilder sb  = new StringBuilder();
            StringWriter  sw  = new StringWriter(sb);
            XmlTextWriter xml = new XmlTextWriter(sw);

            xml.WriteStartElement("testsuites");
            xml.WriteAttributeString("tests", contexts.Examples().Count().ToString());
            xml.WriteAttributeString("errors", "0");
            xml.WriteAttributeString("failures", contexts.Failures().Count().ToString());
            xml.WriteAttributeString("skip", contexts.Pendings().Count().ToString());

            contexts.Do(c => this.BuildContext(xml, c));
            xml.WriteEndElement();

            Console.WriteLine(sb.ToString());
        }
Esempio n. 15
0
        public void Write(ContextCollection contexts)
        {
            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);
            XmlTextWriter xml = new XmlTextWriter(sw);

            xml.WriteStartElement("Contexts");
            xml.WriteAttributeString("TotalSpecs", contexts.Examples().Count().ToString());
            xml.WriteAttributeString("TotalFailed", contexts.Failures().Count().ToString());
            xml.WriteAttributeString("TotalPending", contexts.Pendings().Count().ToString());

            xml.WriteAttributeString("RunDate", DateTime.Now.ToString());
            contexts.Do(c => this.BuildContext(xml, c));
            xml.WriteEndElement();

            Console.WriteLine(sb.ToString());
        }
Esempio n. 16
0
        public void Write(ContextCollection contexts)
        {
            StringBuilder sb  = new StringBuilder();
            StringWriter  sw  = new StringWriter(sb);
            XmlTextWriter xml = new XmlTextWriter(sw);

            xml.WriteStartElement("Contexts");
            xml.WriteAttributeString("TotalSpecs", contexts.Examples().Count().ToString());
            xml.WriteAttributeString("TotalFailed", contexts.Failures().Count().ToString());
            xml.WriteAttributeString("TotalPending", contexts.Pendings().Count().ToString());

            xml.WriteAttributeString("RunDate", DateTime.Now.ToString());
            contexts.Do(c => this.BuildContext(xml, c));
            xml.WriteEndElement();

            Console.WriteLine(sb.ToString());
        }
Esempio n. 17
0
        public void Write(ContextCollection contexts)
        {
            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);
            XmlTextWriter xml = new XmlTextWriter(sw);

            xml.WriteStartElement("testsuites");
            xml.WriteAttributeString("tests", contexts.Examples().Count().ToString());
            xml.WriteAttributeString("errors", "0");
            xml.WriteAttributeString("failures", contexts.Failures().Count().ToString());
            xml.WriteAttributeString("skip", contexts.Pendings().Count().ToString());

            contexts.Do(c => this.BuildContext(xml, c));
            xml.WriteEndElement();

            Console.WriteLine(sb.ToString());
        }
Esempio n. 18
0
        public void Write(ContextCollection contexts)
        {
            StringBuilder   sb         = new StringBuilder();
            StringWriter    sw         = new StringWriter(sb);
            XmlWriteWrapper xmlWrapper = new XmlWriteWrapper(sw);

            var xml = xmlWrapper.Xml;

            xml.WriteStartElement("testsuites");
            xml.WriteAttributeString("tests", contexts.Examples().Count().ToString());
            xml.WriteAttributeString("errors", "0");
            xml.WriteAttributeString("failures", contexts.Failures().Count().ToString());
            xml.WriteAttributeString("skip", contexts.Pendings().Count().ToString());

            contexts.Do(c => this.BuildContext(xmlWrapper, c));

            xml.WriteEndElement();
            xml.Flush();

            var  results        = sb.ToString();
            bool didWriteToFile = false;

            if (Options.ContainsKey("file"))
            {
                var filePath = Path.Combine(Directory.GetCurrentDirectory(), Options["file"]);

                using (var stream = new FileStream(filePath, FileMode.Create))
                    using (var writer = new StreamWriter(stream, Encoding.Unicode))
                    {
                        writer.WriteLine(results);
                        Console.WriteLine("Test results published to: {0}".With(filePath));
                    }

                didWriteToFile = true;
            }
            if (didWriteToFile && Options.ContainsKey("console"))
            {
                Console.WriteLine(results);
            }

            if (!didWriteToFile)
            {
                Console.WriteLine(results);
            }
        }
Esempio n. 19
0
        public void Write(ContextCollection contexts)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("<html>");
            sb.AppendLine("<head>");
            sb.AppendLine("<style type=\"text/css\">");
            sb.AppendLine("body {font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:12px;}");
            sb.AppendLine("  span {padding: 0.5em}");
            sb.AppendLine("  ul {margin-top: 0px}");
            sb.AppendLine("  .results {background-color: #FFFFCC; border:1px solid #d8d8d8; font-weight:bold; white-space: pre-wrap; text-align: center; padding: 0.5em}");
            sb.AppendLine("  .context-parent {border:1px solid #d8d8d8; margin-bottom: 1em;}");
            sb.AppendLine("  .context-parent-title {border:1px solid #d8d8d8;font-weight:bold; padding: 0.5em;background-color:#d8d8d8}");
            sb.AppendLine("  .context-parent-body {padding: 1em 2em 1em 0;}");
            sb.AppendLine("  .context-parent-name {font-weight:bold;}");
            sb.AppendLine("  .spec-passed {font-weight:bold; color:green;}");
            sb.AppendLine("  .spec-failed {font-weight:bold; color:#FF0000;}");
            sb.AppendLine("  .spec-pending {font-weight:bold; color:#0000FF;}");
            sb.AppendLine("  .spec-exception {background-color: #FFD2CF; border:1px solid #FF828D;padding: 1em; font-size:11px; white-space: pre-wrap; padding: 0.5em}");
            sb.AppendLine("  .run-date {color:grey; font-size:x-small;}");
            sb.AppendLine("</style>");
            sb.AppendLine("</head>");
            sb.AppendLine("<body>");

            sb.AppendLine();
            sb.Append("<div class=\"results\">");
            sb.AppendFormat("<div>Assembly: {0}</div>", ((((NSpec.Domain.ClassContext)(contexts.FirstOrDefault())).type).Assembly).FullName);
            sb.AppendFormat("Specs:<span>{0}</span>", contexts.Examples().Count());
            sb.AppendFormat("Failed:<span class=\"spec-failed\">{0}</span>", contexts.Failures().Count());
            sb.AppendFormat("Pending:<span class=\"spec-pending\">{0}</span>", contexts.Pendings().Count());
            sb.AppendFormat("<div class=\"run-date\">Run Date: {0}</div>", DateTime.Now);
            sb.Append("</div>");
            sb.AppendLine();
            sb.AppendLine("<br />");

            contexts.Do(c => this.BuildParentContext(sb, c));

            sb.AppendLine("</html>");
            sb.AppendLine("</body>");

            Console.WriteLine(sb.ToString());
        }
Esempio n. 20
0
        public void Write(ContextCollection contexts)
        {
            contexts.Do(c => this.tiddlers.Add(c.Name, this.BuildTiddlerFrom(c)));

            StringBuilder menuItemsOutput = new StringBuilder();
            StringBuilder tiddlersOutput = new StringBuilder();
            foreach (var context in this.tiddlers.Keys)
            {
                menuItemsOutput.AppendFormat("[[{0}]]", context);
                menuItemsOutput.AppendLine();

                tiddlersOutput.Append(this.tiddlers[context]);
            }
            int examplesCount = contexts.Examples().Count();
            int failuresCount = contexts.Failures().Count();
            int pendingsCount = contexts.Pendings().Count();

            this.WriteTiddlyWiki(menuItemsOutput.ToString(), tiddlersOutput.ToString(),
                                 examplesCount, failuresCount, pendingsCount);
        }
Esempio n. 21
0
        public void Write(ContextCollection contexts)
        {
            contexts.Do(c => this.tiddlers.Add(c.Name, this.BuildTiddlerFrom(c)));

            StringBuilder menuItemsOutput = new StringBuilder();
            StringBuilder tiddlersOutput  = new StringBuilder();

            foreach (var context in this.tiddlers.Keys)
            {
                menuItemsOutput.AppendFormat("[[{0}]]", context);
                menuItemsOutput.AppendLine();

                tiddlersOutput.Append(this.tiddlers[context]);
            }
            int examplesCount = contexts.Examples().Count();
            int failuresCount = contexts.Failures().Count();
            int pendingsCount = contexts.Pendings().Count();

            this.WriteTiddlyWiki(menuItemsOutput.ToString(), tiddlersOutput.ToString(),
                                 examplesCount, failuresCount, pendingsCount);
        }
Esempio n. 22
0
        public void Write(ContextCollection contexts)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("<html>");
            sb.AppendLine("<head>");
            sb.AppendLine("<style type=\"text/css\">");
            sb.AppendLine("  span {padding: 0.5em}");
            sb.AppendLine("  ul {margin-top: 0px}");
            sb.AppendLine("  .results {background-color: #FFFFCC; border-color: #000000; border-style: dashed; border-width: thin; font-weight:bold; white-space: pre-wrap; text-align: center; padding: 0.5em}");
            sb.AppendLine("  .context-parent {border-color: #000000; border-style: dashed; border-width: thin; margin-bottom: 1em;}");
            sb.AppendLine("  .context-parent-title {background-color: #6699FF; border-color: #000000; border-bottom-style: dashed; border-width: thin; font-weight:bold; padding: 0.5em}");
            sb.AppendLine("  .context-parent-body {padding: 1em 2em 1em 0;}");
            sb.AppendLine("  .context-parent-name {font-weight:bold;}");
            sb.AppendLine("  .spec-passed {font-weight:bold; color:green;}");
            sb.AppendLine("  .spec-failed {font-weight:bold; color:#FF0000;}");
            sb.AppendLine("  .spec-pending {font-weight:bold; color:#0000FF;}");
            sb.AppendLine("  .spec-exception {background-color: #FFD2CF; border-color: #FF828D; border-style: dashed; border-width: thin; padding: 1em; font-size:small; white-space: pre-wrap; padding: 0.5em}");
            sb.AppendLine("  .run-date {color:grey; font-size:x-small;}");
            sb.AppendLine("</style>");
            sb.AppendLine("</head>");
            sb.AppendLine("<body>");

            sb.AppendLine();
            sb.Append("<div class=\"results\">");
            sb.AppendFormat("Specs:<span>{0}</span>", contexts.Examples().Count());
            sb.AppendFormat("Failed:<span class=\"spec-failed\">{0}</span>", contexts.Failures().Count());
            sb.AppendFormat("Pending:<span class=\"spec-pending\">{0}</span>", contexts.Pendings().Count());
            sb.AppendFormat("<div class=\"run-date\">Run Date: {0}</div>", DateTime.Now);
            sb.Append("</div>");
            sb.AppendLine();
            sb.AppendLine("<br />");

            contexts.Do(c => this.BuildParentContext(sb, c));

            sb.AppendLine("</html>");
            sb.AppendLine("</body>");

            Console.WriteLine(sb.ToString());
        }
Esempio n. 23
0
        public void Write(ContextCollection contexts)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("<html>");
            sb.AppendLine("<head>");
            sb.AppendLine("<style type=\"text/css\">");
            sb.AppendLine("  span {padding: 0.5em}");
            sb.AppendLine("  ul {margin-top: 0px}");
            sb.AppendLine("  .results {background-color: #FFFFCC; border-color: #000000; border-style: dashed; border-width: thin; font-weight:bold; white-space: pre-wrap; text-align: center; padding: 0.5em}");
            sb.AppendLine("  .context-parent {border-color: #000000; border-style: dashed; border-width: thin; margin-bottom: 1em;}");
            sb.AppendLine("  .context-parent-title {background-color: #6699FF; border-color: #000000; border-bottom-style: dashed; border-width: thin; font-weight:bold; padding: 0.5em}");
            sb.AppendLine("  .context-parent-body {padding: 1em 2em 1em 0;}");
            sb.AppendLine("  .context-parent-name {font-weight:bold;}");
            sb.AppendLine("  .spec-passed {font-weight:bold; color:green;}");
            sb.AppendLine("  .spec-failed {font-weight:bold; color:#FF0000;}");
            sb.AppendLine("  .spec-pending {font-weight:bold; color:#0000FF;}");
            sb.AppendLine("  .spec-exception {background-color: #FFD2CF; border-color: #FF828D; border-style: dashed; border-width: thin; padding: 1em; font-size:small; white-space: pre-wrap; padding: 0.5em}");
            sb.AppendLine("  .run-date {color:grey; font-size:x-small;}");
            sb.AppendLine("</style>");
            sb.AppendLine("</head>");
            sb.AppendLine("<body>");

            sb.AppendLine();
            sb.Append("<div class=\"results\">");
            sb.AppendFormat("Specs:<span>{0}</span>", contexts.Examples().Count());
            sb.AppendFormat("Failed:<span class=\"spec-failed\">{0}</span>", contexts.Failures().Count());
            sb.AppendFormat("Pending:<span class=\"spec-pending\">{0}</span>", contexts.Pendings().Count());
            sb.AppendFormat("<div class=\"run-date\">Run Date: {0}</div>", DateTime.Now);
            sb.Append("</div>");
            sb.AppendLine();
            sb.AppendLine("<br />");

            contexts.Do(c => this.BuildParentContext(sb, c));

            sb.AppendLine("</html>");
            sb.AppendLine("</body>");

            Console.WriteLine(sb.ToString());
        }
Esempio n. 24
0
        public string FailureSummary(ContextCollection contexts)
        {
            if (contexts.Failures().Count() == 0) return "";

            var summary = "\n" + "**** FAILURES ****" + "\n";
            contexts.Failures().Where(t => ExamplesToProcess.Count == 0 || ExamplesToProcess.Contains(GetSpecName(t))).Do(f => summary += WriteFailure(f));
            return summary;
        }
Esempio n. 25
0
        public string Summary(ContextCollection contexts)
        {
            var condition = new Func<ExampleBase, bool>(t => ExamplesToProcess.Count == 0 || ExamplesToProcess.Contains(GetSpecName(t)));

            var summary = "{0} Examples, {1} Failed, {2} Pending".With(
                contexts.Examples().Where(condition).Count(),
                contexts.Failures().Where(condition).Count(),
                contexts.Pendings().Where(condition).Count()
                );

            if (contexts.AnyTaggedWithFocus())
            {
                summary += "\n" + "\n" + @"NSpec found context/examples tagged with ""focus"" and only ran those.";
            }

            return summary;
        }
        public void Write(ContextCollection contexts)
        {
            var examples = contexts.Examples().Count();
            var failures = contexts.Failures().Count();

            _sessionResults.SessionRunState = GetSessionRunState(examples, failures);

            contexts.Examples().Each(e => _sessionResults.TestResults.Add(e.ToTestResult()));
        }
Esempio n. 27
0
 public void should_aggregate_failures()
 {
     contexts.Failures().Count().should_be(1);
 }