Example #1
0
        /// <summary>
        /// Write the result of a test run according to a spec.
        /// </summary>
        /// <param name="result">The test result</param>
        /// <param name="spec">An output specification</param>
        public void WriteResultFile(ITestResult result, OutputSpecification spec)
        {
            string       outputPath   = Path.Combine(_workDirectory, spec.OutputPath);
            OutputWriter outputWriter = null;

            switch (spec.Format)
            {
            case "nunit3":
                outputWriter = new NUnit3XmlOutputWriter();
                break;

            case "nunit2":
                outputWriter = new NUnit2XmlOutputWriter();
                break;

            //case "user":
            //    Uri uri = new Uri(Assembly.GetExecutingAssembly().CodeBase);
            //    string dir = Path.GetDirectoryName(uri.LocalPath);
            //    outputWriter = new XmlTransformOutputWriter(Path.Combine(dir, spec.Transform));
            //    break;

            default:
                throw new ArgumentException(
                          string.Format("Invalid XML output format '{0}'", spec.Format),
                          "spec");
            }

            outputWriter.WriteResultFile(result, outputPath);
            Console.WriteLine("Results ({0}) saved as {1}", spec.Format, outputPath);
        }
        /// <summary>
        /// Write the result of a test run according to a spec.
        /// </summary>
        /// <param name="result">The test result</param>
        /// <param name="spec">An output specification</param>
        public void WriteResultFile(ITestResult result, OutputSpecification spec)
        {
            string outputPath = Path.Combine(_workDirectory, spec.OutputPath);
            OutputWriter outputWriter = null;

            switch (spec.Format)
            {
                case "nunit3":
                    outputWriter = new NUnit3XmlOutputWriter();
                    break;

                case "nunit2":
                    outputWriter = new NUnit2XmlOutputWriter();
                    break;

                //case "user":
                //    Uri uri = new Uri(Assembly.GetExecutingAssembly().CodeBase);
                //    string dir = Path.GetDirectoryName(uri.LocalPath);
                //    outputWriter = new XmlTransformOutputWriter(Path.Combine(dir, spec.Transform));
                //    break;

                default:
                    throw new ArgumentException(
                        string.Format("Invalid XML output format '{0}'", spec.Format),
                        "spec");
            }

            outputWriter.WriteResultFile(result, outputPath);
            Console.WriteLine("Results ({0}) saved as {1}", spec.Format, outputPath);
        }
        protected virtual void PublishResults(TestResult testResults)
        {
            TestResultsConfig.PrintConfig();

              Log.Info(this.tag, "Publishing results : " + DateTime.Now +
                    "\nTotal count : {0}, Failed : {1}",
            testResults.AssertCount,
            testResults.FailCount);

              if (TestResultsConfig.IsRemote)
              {
            switch (TestResultsConfig.TestsResultsFormat)
            {
              case "plain_text":
            //          We already published test results because in this case we publish each test results separately. See SetTextWriterForAndroidTestRunner() method.
            return;
              case "nunit2":
            var nunit2Writer = new NUnit2XmlOutputWriter(this.testsStartTime);
            var tcpwriter = this.NetworkWriter;

            nunit2Writer.WriteResultFile(testResults, tcpwriter);
            tcpwriter.Close();

            Log.Info(this.tag, "Published tests results in nunit2 format");
            return;
              case "nunit3":
            var nunit3Writer = new NUnit3XmlOutputWriter(this.testsStartTime);
            var newtworkWriter = this.NetworkWriter;

            nunit3Writer.WriteResultFile(testResults, newtworkWriter);
            newtworkWriter.Close();

            Log.Info(this.tag, "Published tests results in nunit3 format");
            return;
            }
              }
              else
              {
            //      If we don't need to send test results to remote server, just return.
            return;
              }
        }
Example #4
0
		public void CloseWriter ()
		{
			var outputWriter = new NUnit2XmlOutputWriter ();
			var tempFilePath = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments), "output.xml");
			outputWriter.WriteResultFile (TestResult,tempFilePath);
			var data = File.ReadAllBytes (tempFilePath);
			if (Writer is TcpTextWriter) {

				(Writer as TcpTextWriter).Write (data, 0, data.Length);
				
				Writer.Close ();
			} else {			
				int total = passed + inconclusive + failed; // ignored are *not* run
				Writer.WriteLine ("Tests run: {0} Passed: {1} Inconclusive: {2} Failed: {3} Ignored: {4}", total, passed, inconclusive, failed, ignored);

			}
			
			Writer = null;
		}