Test GetAssemblyTest(IAssemblyInfo assembly, Test parentTest, Version frameworkVersion, bool populateRecursively) { NSpecAssemblyTest assemblyTest; if (!assemblyTests.TryGetValue(assembly, out assemblyTest)) { assemblyTest = new NSpecAssemblyTest(assembly.Name, assembly, frameworkVersion); assemblyTest.Kind = TestKinds.Assembly; ModelUtils.PopulateMetadataFromAssembly(assembly, assemblyTest.Metadata); string frameworkName = String.Format("NSpec v{0}", frameworkVersion); assemblyTest.Metadata.SetValue(MetadataKeys.Framework, frameworkName); assemblyTest.Metadata.SetValue(MetadataKeys.File, assembly.Path); assemblyTest.Kind = TestKinds.Assembly; parentTest.AddChild(assemblyTest); assemblyTests.Add(assembly, assemblyTest); } if (populateRecursively) { var reflector = new NSpec.Domain.Reflector(assembly.Path); var finder = new SpecFinder(reflector); var builder = new ContextBuilder(finder, new DefaultConventions()); ContextCollection contexts = builder.Contexts(); contexts.Build(); contexts.Do(c => assemblyTest.AddChild(this.CreateGallioTestFrom(c))); } return(assemblyTest); }
public void Write( ContextCollection contexts ) { contexts.Do( c => Console.WriteLine( Write( c ) ) ); Console.WriteLine( FailureSummary( contexts ) ); Console.WriteLine( Summary( contexts ) ); }
public void Write(ContextCollection contexts) { contexts.Do(c => Console.WriteLine(Write(c))); Console.WriteLine(FailureSummary(contexts)); Console.WriteLine(Summary(contexts)); }
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()); }
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()); }
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); } }
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()); }
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); }
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()); }