コード例 #1
0
        public void SaveLastResult(string fileName)
        {
            XmlResultVisitor resultVisitor
                = new XmlResultVisitor(fileName, this.testResult);

            this.testResult.Accept(resultVisitor);
            resultVisitor.Write();
        }
コード例 #2
0
ファイル: ConsoleUi.cs プロジェクト: nobled/mono
		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();
		}
コード例 #3
0
ファイル: XmlTest.cs プロジェクト: fotisp/conqat
        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;
            }
        }
コード例 #4
0
ファイル: XmlTest.cs プロジェクト: fotisp/conqat
        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;
            }
        }
コード例 #5
0
ファイル: XmlTest.cs プロジェクト: taoxiease/asegrp
        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();
        }
コード例 #6
0
ファイル: XmlTest.cs プロジェクト: taoxiease/asegrp
        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");
        }
コード例 #7
0
ファイル: NUnit2Task.cs プロジェクト: skolima/NAnt
        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);
            }
        }
コード例 #8
0
ファイル: TestLoader.cs プロジェクト: nobled/mono
		public void SaveLastResult( string fileName )
		{
			XmlResultVisitor resultVisitor 
				= new XmlResultVisitor( fileName, this.testResult );
			this.testResult.Accept(resultVisitor);
			resultVisitor.Write();
		}
コード例 #9
0
ファイル: NUnutHelper.cs プロジェクト: Xarlot/reportformatter
 public static void CreateXmlOutput(TestResult result, TextWriter w)
 {
     XmlResultVisitor visitor = new XmlResultVisitor(w, result);
     result.Accept(visitor);
     visitor.Write();
 }