public void SaveLastResult(string fileName) { XmlResultVisitor resultVisitor = new XmlResultVisitor(fileName, this.testResult); this.testResult.Accept(resultVisitor); resultVisitor.Write(); }
private static string CreateXmlOutput( TestResult result ) { StringBuilder builder = new StringBuilder(); XmlResultVisitor resultVisitor = new XmlResultVisitor(new StringWriter( builder ), result); result.Accept(resultVisitor); resultVisitor.Write(); return builder.ToString(); }
private void runSchemaValidatorTest(string reportFileName, CultureInfo testCulture) { // Preserve current culture CultureInfo previousCulture = Thread.CurrentThread.CurrentCulture; // Enable test culture Thread.CurrentThread.CurrentCulture = testCulture; try { string testsDll = "mock-assembly.dll"; TestSuiteBuilder builder = new TestSuiteBuilder(); Test suite = builder.Build( new TestPackage( testsDll ) ); TestResult result = suite.Run(NullListener.NULL); XmlResultVisitor visitor = new XmlResultVisitor(reportFileName, result); result.Accept(visitor); visitor.Write(); SchemaValidator validator = new SchemaValidator(reportFileName, schemaFile.Path); Assert.IsTrue(validator.Validate(), "validate failed"); } finally { // Restore previous culture Thread.CurrentThread.CurrentCulture = previousCulture; } }
private void runSchemaValidatorTest(TextWriter writer, CultureInfo testCulture) { // Preserve current culture CultureInfo previousCulture = Thread.CurrentThread.CurrentCulture; // Enable test culture Thread.CurrentThread.CurrentCulture = testCulture; try { string testsDll = "mock-assembly.dll"; TestSuiteBuilder builder = new TestSuiteBuilder(); Test suite = builder.Build( new TestPackage( testsDll ) ); TestResult result = suite.Run(NullListener.NULL); XmlResultVisitor visitor = new XmlResultVisitor(writer, result); result.Accept(visitor); visitor.Write(); } finally { // Restore previous culture Thread.CurrentThread.CurrentCulture = previousCulture; } }
private void runSchemaValidatorTest(TextWriter writer) { string testsDll = "mock-assembly.dll"; TestSuiteBuilder builder = new TestSuiteBuilder(); Test suite = builder.Build( new TestPackage( testsDll ) ); TestResult result = suite.Run(NullListener.NULL); XmlResultVisitor visitor = new XmlResultVisitor(writer, result); result.Accept(visitor); visitor.Write(); }
private void runSchemaValidatorTest(string reportFileName) { string testsDll = "mock-assembly.dll"; TestSuiteBuilder builder = new TestSuiteBuilder(); Test suite = builder.Build( new TestPackage( testsDll ) ); TestResult result = suite.Run(NullListener.NULL); XmlResultVisitor visitor = new XmlResultVisitor(reportFileName, result); result.Accept(visitor); visitor.Write(); SchemaValidator validator = new SchemaValidator(reportFileName, schemaFile.Path); Assert.IsTrue(validator.Validate(), "validate failed"); }
private void FormatResult(NUnit2Test testElement, TestResult result) { // temp file for storing test results string xmlResultFile = Path.GetTempFileName(); // permanent file for storing test results string outputFile = null; try { XmlResultVisitor resultVisitor = new XmlResultVisitor(xmlResultFile, result); result.Accept(resultVisitor); resultVisitor.Write(); foreach (FormatterElement formatter in FormatterElements) { if (formatter.Type == FormatterType.Xml) { if (formatter.UseFile) { // determine file name for output file outputFile = result.Name + "-results" + formatter.Extension; if (formatter.OutputDirectory != null) { // ensure output directory exists if (!formatter.OutputDirectory.Exists) { formatter.OutputDirectory.Create(); } // combine output directory and result filename outputFile = Path.Combine(formatter.OutputDirectory.FullName, Path.GetFileName(outputFile)); } // copy the temp result file to permanent location File.Copy(xmlResultFile, outputFile, true); } else { using (StreamReader reader = new StreamReader(xmlResultFile)) { // strip off the xml header reader.ReadLine(); StringBuilder builder = new StringBuilder(); while (reader.Peek() > -1) { builder.Append(reader.ReadLine().Trim()).Append( Environment.NewLine); } Log(Level.Info, builder.ToString()); } } } else if (formatter.Type == FormatterType.Plain) { TextWriter writer; if (formatter.UseFile) { // determine file name for output file outputFile = result.Name + "-results" + formatter.Extension; if (formatter.OutputDirectory != null) { // ensure output directory exists if (!formatter.OutputDirectory.Exists) { formatter.OutputDirectory.Create(); } // combine output directory and result filename outputFile = Path.Combine(formatter.OutputDirectory.FullName, Path.GetFileName(outputFile)); } writer = new StreamWriter(outputFile); } else { writer = new LogWriter(this, Level.Info, CultureInfo.InvariantCulture); } CreateSummaryDocument(xmlResultFile, writer, testElement); writer.Close(); } } } catch (Exception ex) { throw new BuildException("Test results could not be" + " formatted.", Location, ex); } finally { // make sure temp file with test results is removed File.Delete(xmlResultFile); } }
public void SaveLastResult( string fileName ) { XmlResultVisitor resultVisitor = new XmlResultVisitor( fileName, this.testResult ); this.testResult.Accept(resultVisitor); resultVisitor.Write(); }
public static void CreateXmlOutput(TestResult result, TextWriter w) { XmlResultVisitor visitor = new XmlResultVisitor(w, result); result.Accept(visitor); visitor.Write(); }