Ejemplo n.º 1
0
		public static UnitTestResult CreateIgnored (string message)
		{
			UnitTestResult res = new UnitTestResult ();
			res.status = ResultStatus.Ignored;
			res.Message = message;
			return res;
		}
Ejemplo n.º 2
0
		public static UnitTestResult CreateInconclusive (string message)
		{
			UnitTestResult res = new UnitTestResult ();
			res.status = ResultStatus.Inconclusive;
			res.Message = message;
			return res;
		}
Ejemplo n.º 3
0
		public void RegisterResult (string configuration, UnitTest test, UnitTestResult result)
		{
			//This method can be called from multiple threads when remote process(test runner) is responding
			//This lock is protecting collections fileCache, record.Tests and record.Results
			lock (fileCache) {
				string aname = test.StoreRelativeName;

				TestRecord root = GetRootRecord (configuration, result.TestDate);
				if (root == null) {
					root = new TestRecord ();
					fileCache [GetRootFileName (configuration, result.TestDate)] = root;
				}
				root.Modified = true;
				TestRecord record = root;

				if (aname.Length > 0) {
					string [] path = test.StoreRelativeName.Split ('.');
					foreach (string p in path) {
						TestRecord ctr = record.Tests != null ? record.Tests [p] : null;
						if (ctr == null) {
							ctr = new TestRecord ();
							ctr.Name = p;
							if (record.Tests == null)
								record.Tests = new TestRecordCollection ();
							record.Tests.Add (ctr);
						}
						record = ctr;
					}
				}

				if (record.Results == null)
					record.Results = new UnitTestResultCollection ();
				record.Results.Add (result);
			}
		}
		public void RegisterResult (string configuration, UnitTest test, UnitTestResult result)
		{
			string aname = test.StoreRelativeName;
			
			TestRecord root = GetRootRecord (configuration, result.TestDate);
			if (root == null) {
				root = new TestRecord ();
				fileCache [GetRootFileName (configuration, result.TestDate)] = root;
			}
			root.Modified = true;
			TestRecord record = root;
			
			if (aname.Length > 0) {
				string[] path = test.StoreRelativeName.Split ('.');
				foreach (string p in path) {
					TestRecord ctr = record.Tests != null ? record.Tests [p] : null;
					if (ctr == null) {
						ctr = new TestRecord ();
						ctr.Name = p;
						if (record.Tests == null)
							record.Tests = new TestRecordCollection ();
						record.Tests.Add (ctr);
					}
					record = ctr;
				}
			}
			
			if (record.Results == null)
				record.Results = new UnitTestResultCollection ();
			record.Results.Add (result);
		}
Ejemplo n.º 5
0
		public static UnitTestResult CreateFailure (Exception ex)
		{
			UnitTestResult res = new UnitTestResult ();
			res.status = ResultStatus.Failure;
			res.Message = ex.Message;
			res.stackTrace = ex.StackTrace;
			return res;
		}
Ejemplo n.º 6
0
		public static UnitTestResult CreateFailure (string message, Exception ex)
		{
			UnitTestResult res = new UnitTestResult ();
			res.status = ResultStatus.Failure;
			res.Message = message;
			if (ex != null)
				res.stackTrace = ex.Message + "\n" + ex.StackTrace;
			return res;
		}
Ejemplo n.º 7
0
		void ClearResults ()
		{
			if (failuresTreeView.IsRealized)
				failuresTreeView.ScrollToPoint (0, 0);

			results.Clear ();

			error = null;
			errorMessage = null;

			failuresStore.Clear ();
			outputView.Buffer.Clear ();
			outIters.Clear ();
			progressBar.Fraction = 0;
			progressBar.Text = "";
			testsRun = 0;
			resultSummary = new UnitTestResult ();
			resultLabel.Markup = "";
			resultLabel.Hide ();
			labels.Show ();
			UpdateCounters ();
		}
Ejemplo n.º 8
0
        void ShowTestResult(UnitTest test, UnitTestResult result)
        {
            if (result.IsSuccess)
            {
                if (!buttonSuccess.Active)
                {
                    return;
                }
                TreeIter testRow = failuresStore.AppendValues(TestStatusIcon.Success, Escape(test.FullName), test);
                failuresTreeView.ScrollToCell(failuresStore.GetPath(testRow), null, false, 0, 0);
            }
            if (result.IsFailure)
            {
                if (!buttonFailures.Active)
                {
                    return;
                }
                string   file       = test.SourceCodeLocation != null ? test.SourceCodeLocation.FileName + ":" + test.SourceCodeLocation.Line : null;
                TreeIter testRow    = failuresStore.AppendValues(TestStatusIcon.Failure, Escape(test.FullName), test, file);
                bool     hasMessage = !string.IsNullOrEmpty(result.Message);

                if (hasMessage)
                {
                    var       sb = StringBuilderCache.Allocate();
                    string    curLineText;
                    int       curLine       = 1;
                    const int maxLineLength = 255;
                    const int maxLineNumber = 255;
                    sb.Append("<span font='");
                    sb.Append(IdeServices.FontService.MonospaceFontName);
                    sb.Append("'>");
                    using (var sr = new StringReader(result.Message)) {
                        while (null != (curLineText = sr.ReadLine()))
                        {
                            if (curLineText == null)
                            {
                                continue;
                            }
                            if (curLine < maxLineNumber)
                            {
                                if (curLineText.Length > maxLineLength)
                                {
                                    sb.Append(curLineText, 0, maxLineLength);
                                    sb.AppendLine("…");
                                }
                                else
                                {
                                    sb.AppendLine(curLineText);
                                }
                            }
                            curLine++;
                        }
                    }
                    if (curLine > maxLineNumber)
                    {
                        sb.Append("<span foreground='darkgrey'>");
                        sb.Append(GettextCatalog.GetString("(+{0} lines not shown - see output view for full result message)", curLine - maxLineNumber));
                        sb.Append("</span>");
                    }
                    sb.Append("</span>");
                    failuresStore.AppendValues(testRow, null, StringBuilderCache.ReturnAndFree(sb), test, null, 0, ErrorMessage);
                }

                if (!string.IsNullOrEmpty(result.StackTrace))
                {
                    TreeIter row = testRow;
                    if (hasMessage)
                    {
                        row = failuresStore.AppendValues(testRow, null, GettextCatalog.GetString("Stack Trace"), test, null, 0, StackTrace);
                    }
                    AddStackTrace(row, result.StackTrace, test);
                }
                failuresTreeView.ScrollToCell(failuresStore.GetPath(testRow), null, false, 0, 0);
            }
            if (result.IsNotRun)
            {
                if (!buttonIgnored.Active)
                {
                    return;
                }
                TreeIter testRow = failuresStore.AppendValues(TestStatusIcon.NotRun, Escape(test.FullName), test);
                if (result.Message != null)
                {
                    failuresStore.AppendValues(testRow, null, Escape(result.Message), test);
                }
                failuresTreeView.ScrollToCell(failuresStore.GetPath(testRow), null, false, 0, 0);
            }
            if (result.IsInconclusive)
            {
                if (!buttonInconclusive.Active)
                {
                    return;
                }
                TreeIter testRow = failuresStore.AppendValues(TestStatusIcon.Inconclusive, Escape(test.FullName), test);
                if (result.Message != null)
                {
                    failuresStore.AppendValues(testRow, null, Escape(result.Message), test);
                }
                failuresTreeView.ScrollToCell(failuresStore.GetPath(testRow), null, false, 0, 0);
            }

            string   msg = GettextCatalog.GetString("Running {0} ...", test.FullName);
            TextIter it  = outputView.Buffer.EndIter;

            outIters [test] = it.Offset;
            outputView.Buffer.InsertWithTags(ref it, msg, bold);
            outputView.Buffer.Insert(ref it, "\n");
            if (result.ConsoleOutput != null)
            {
                outputView.Buffer.Insert(ref it, result.ConsoleOutput);
            }
            if (result.ConsoleError != null)
            {
                outputView.Buffer.Insert(ref it, result.ConsoleError);
            }
            if (!string.IsNullOrEmpty(result.Message))
            {
                outputView.Buffer.Insert(ref it, GettextCatalog.GetString("Result message:"));
                outputView.Buffer.Insert(ref it, "\n");
                outputView.Buffer.Insert(ref it, result.Message);
            }
            outputView.ScrollMarkOnscreen(outputView.Buffer.InsertMark);
        }
Ejemplo n.º 9
0
		protected override void Initialize (IPadWindow window)
		{
			this.window = window;
			
			DockItemToolbar toolbar = window.GetToolbar (DockPositionType.Top);
			
			buttonSuccess = new ToggleButton ();
			buttonSuccess.Label = GettextCatalog.GetString ("Successful Tests");
			buttonSuccess.Active = false;
			buttonSuccess.Image = new ImageView (TestStatusIcon.Success);
			buttonSuccess.Image.Show ();
			buttonSuccess.Toggled += new EventHandler (OnShowSuccessfulToggled);
			buttonSuccess.TooltipText = GettextCatalog.GetString ("Show Successful Tests");
			toolbar.Add (buttonSuccess);

			buttonInconclusive = new ToggleButton ();
			buttonInconclusive.Label = GettextCatalog.GetString ("Inconclusive Tests");
			buttonInconclusive.Active = true;
			buttonInconclusive.Image = new ImageView (TestStatusIcon.Inconclusive);
			buttonInconclusive.Image.Show ();
			buttonInconclusive.Toggled += new EventHandler (OnShowInconclusiveToggled);
			buttonInconclusive.TooltipText = GettextCatalog.GetString ("Show Inconclusive Tests");
			toolbar.Add (buttonInconclusive);
			
			buttonFailures = new ToggleButton ();
			buttonFailures.Label = GettextCatalog.GetString ("Failed Tests");
			buttonFailures.Active = true;
			buttonFailures.Image = new ImageView (TestStatusIcon.Failure);
			buttonFailures.Image.Show ();
			buttonFailures.Toggled += new EventHandler (OnShowFailuresToggled);
			buttonFailures.TooltipText = GettextCatalog.GetString ("Show Failed Tests");
			toolbar.Add (buttonFailures);

			buttonIgnored = new ToggleButton ();
			buttonIgnored.Label = GettextCatalog.GetString ("Ignored Tests");
			buttonIgnored.Active = true;
			buttonIgnored.Image = new ImageView (TestStatusIcon.NotRun);
			buttonIgnored.Image.Show ();
			buttonIgnored.Toggled += new EventHandler (OnShowIgnoredToggled);
			buttonIgnored.TooltipText = GettextCatalog.GetString ("Show Ignored Tests");
			toolbar.Add (buttonIgnored);
			
			buttonOutput = new ToggleButton ();
			buttonOutput.Label = GettextCatalog.GetString ("Output");
			buttonOutput.Active = false;
			buttonOutput.Image = new ImageView (MonoDevelop.Ide.Gui.Stock.OutputIcon, IconSize.Menu);
			buttonOutput.Image.Show ();
			buttonOutput.Toggled += new EventHandler (OnShowOutputToggled);
			buttonOutput.TooltipText = GettextCatalog.GetString ("Show Output");
			toolbar.Add (buttonOutput);
			
			toolbar.Add (new SeparatorToolItem ());
			
			buttonRun = new Button ();
			buttonRun.Label = GettextCatalog.GetString ("Rerun Tests");
			buttonRun.Image = new ImageView ("md-execute-all", IconSize.Menu);
			buttonRun.Image.Show ();
			buttonRun.Sensitive = false;
			toolbar.Add (buttonRun);
			
			buttonStop = new Button (new ImageView (Ide.Gui.Stock.Stop, Gtk.IconSize.Menu));
			toolbar.Add (buttonStop);
			toolbar.ShowAll ();
			
			buttonStop.Clicked += new EventHandler (OnStopClicked);
			buttonRun.Clicked += new EventHandler (OnRunClicked);
			
			// Run panel
			
			DockItemToolbar runPanel = window.GetToolbar (DockPositionType.Bottom);
			
			infoSep = new VSeparator ();
			
			resultLabel.UseMarkup = true;
			infoCurrent.Ellipsize = Pango.EllipsizeMode.Start;
			infoCurrent.WidthRequest = 0;
			runPanel.Add (resultLabel);
			runPanel.Add (progressBar);
			runPanel.Add (infoCurrent, true, 10);	
			
			labels = new HBox (false, 10);
			
			infoLabel.UseMarkup = true;

			labels.PackStart (infoLabel, true, false, 0);

			runPanel.Add (new Gtk.Label (), true);
			runPanel.Add (labels);
			runPanel.Add (infoSep, false, 10);
			
			progressBar.HeightRequest = infoLabel.SizeRequest ().Height;
			runPanel.ShowAll ();
			progressBar.Hide ();
			infoSep.Hide ();
			resultSummary = new UnitTestResult ();
			UpdateCounters ();
		}
Ejemplo n.º 10
0
		public static UnitTestResult CreateSuccess ()
		{
			UnitTestResult res = new UnitTestResult ();
			res.status = ResultStatus.Success;
			return res;
		}
		public void Add (UnitTestResult test)
		{
			((IList)this).Add (test);
		}
Ejemplo n.º 12
0
 public void EndTest(UnitTest test, UnitTestResult result)
 {
     Runtime.RunInMainThread(delegate {
         monitor.EndTest(test, result);
     });
 }
Ejemplo n.º 13
0
		protected override UnitTestResult OnRun (TestContext testContext)
		{
			UnitTestResult tres = new UnitTestResult ();
			OnBeginTest (testContext);
			
			try {
				foreach (UnitTest t in Tests) {
					if (t.IsExplicit)
						continue;
					UnitTestResult res;
					try {
						res = OnRunChildTest (t, testContext);
						if (testContext.Monitor.CancellationToken.IsCancellationRequested)
							break;
					} catch (Exception ex) {
						res = UnitTestResult.CreateFailure (ex);
					}
					tres.Add (res);
				}
			} finally {
				OnEndTest (testContext);
			}
			return tres;
		}
Ejemplo n.º 14
0
		void ITestProgressMonitor.EndTest (UnitTest test, UnitTestResult result)
		{
			if (test is UnitTestGroup)
				return;
			
			testsRun++;
			ResultRecord rec = new ResultRecord ();
			rec.Test = test;
			rec.Result = result;
			
			resultSummary.Add (result);
			results.Add (rec);
			
			ShowTestResult (test, result);
			
			UpdateCounters ();

			double frac;
			if (testsToRun != 0)
				frac = ((double)testsRun / (double)testsToRun);
			else
				frac = 1;

			frac = Math.Min (1, Math.Max (0, frac));

			progressBar.Fraction = frac;
			progressBar.Text = testsRun + " / " + testsToRun;
		}
Ejemplo n.º 15
0
        void FillTestInformation()
        {
            if (!detailsPad.Visible)
            {
                return;
            }

            if (detailsTest is UnitTestGroup)
            {
                UnitTestGroup group = detailsTest as UnitTestGroup;
                if (infoBook.Page == TestSummaryPage)
                {
                    detailsStore.Clear();
                    foreach (UnitTest t in group.Tests)
                    {
                        UnitTestResult res = t.Results.GetLastResult(chart.CurrentDate);
                        if (res != null)
                        {
                            detailsStore.AppendValues(t, t.Name, res.Passed.ToString(), res.ErrorsAndFailures.ToString(), res.Ignored.ToString());
                        }
                        else
                        {
                            detailsStore.AppendValues(t, t.Name, "", "", "");
                        }
                    }
                }
                else if (infoBook.Page == TestRegressionsPage)
                {
                    regressionStore.Clear();
                    UnitTestCollection regs = detailsTest.GetRegressions(chart.ReferenceDate, chart.CurrentDate);
                    if (regs.Count > 0)
                    {
                        foreach (UnitTest t in regs)
                        {
                            regressionStore.AppendValues(t, t.Name, TestStatusIcon.Failure);
                        }
                    }
                    else
                    {
                        regressionStore.AppendValues(null, GettextCatalog.GetString("No regressions found."));
                    }
                }
                else if (infoBook.Page == TestFailuresPage)
                {
                    failedStore.Clear();
                    UnitTestCollection regs = group.GetFailedTests(chart.CurrentDate);
                    if (regs.Count > 0)
                    {
                        foreach (UnitTest t in regs)
                        {
                            failedStore.AppendValues(t, t.Name, TestStatusIcon.Failure);
                        }
                    }
                    else
                    {
                        failedStore.AppendValues(null, GettextCatalog.GetString("No failed tests found."));
                    }
                }
            }
            else
            {
                UnitTestResult res = detailsTest.Results.GetLastResult(chart.CurrentDate);
                if (infoBook.Page == TestOutputPage)
                {
                    outputView.Buffer.Clear();
                    if (res != null)
                    {
                        outputView.Buffer.InsertAtCursor(res.ConsoleOutput);
                    }
                }
                else if (infoBook.Page == TestResultPage)
                {
                    resultView.Buffer.Clear();
                    if (res != null)
                    {
                        string msg = res.Message + "\n\n" + res.StackTrace;
                        resultView.Buffer.InsertAtCursor(msg);
                    }
                }
            }
        }
Ejemplo n.º 16
0
		public void InitializeTestRun (UnitTest test, CancellationTokenSource cs)
		{
			rootTest = test;
			cancellationSource = cs;
			cs.Token.Register (OnCancel);
			results.Clear ();

			testsToRun = test.CountTestCases ();
			error = null;
			errorMessage = null;
			
			progressBar.Fraction = 0;
			progressBar.Text = "";
			progressBar.Text = "0 / " + testsToRun;
			testsRun = 0;
			resultSummary = new UnitTestResult ();
			UpdateCounters ();
			
			infoSep.Show ();
			infoCurrent.Show ();
			progressBar.Show ();
			resultLabel.Hide ();
			labels.Show ();
			buttonStop.Sensitive = true;
			buttonRun.Sensitive = false;

			if (failuresTreeView.IsRealized)
				failuresTreeView.ScrollToPoint (0, 0);
			
			failuresStore.Clear ();
			outputView.Buffer.Clear ();
			outIters.Clear ();
			cancel = false;
			Running = true;
			
			configuration = IdeApp.Workspace.ActiveConfigurationId;
			
			AddStartMessage ();
		}
Ejemplo n.º 17
0
		public void RegisterResult (TestContext context, UnitTestResult result)
		{
			// Avoid registering results twice
			if (lastResult != null && lastResult.TestDate == context.TestDate)
				return;

			result.TestDate = context.TestDate;
//			if ((int)result.Status == 0)
//				result.Status = ResultStatus.Ignored;

			lastResult = result;
			historicResult = false;
			resultLoaded = true;

			IResultsStore store = GetResultsStore ();
			if (store != null)
				store.RegisterResult (ActiveConfiguration, this, result);
			OnTestStatusChanged ();
		}
Ejemplo n.º 18
0
		public UnitTestResult GetLastResult ()
		{
			if (!resultLoaded) {
				resultLoaded = true;
				lastResult = Results.GetLastResult (DateTime.Now);
				if (lastResult != null)
					historicResult = true;
			}
			return lastResult;
		}
Ejemplo n.º 19
0
        protected override void Initialize(IPadWindow window)
        {
            this.window = window;

            DockItemToolbar toolbar = window.GetToolbar(DockPositionType.Top);

            buttonSuccess                        = new ToggleButton();
            buttonSuccess.Label                  = GettextCatalog.GetString("Successful Tests");
            buttonSuccess.Accessible.Name        = "TestResultsPad.SuccessfulTests";
            buttonSuccess.Accessible.Description = GettextCatalog.GetString("Show the results for the successful tests");
            buttonSuccess.Active                 = false;
            buttonSuccess.Image                  = new ImageView(TestStatusIcon.Success);
            buttonSuccess.Image.Show();
            buttonSuccess.Toggled    += new EventHandler(OnShowSuccessfulToggled);
            buttonSuccess.TooltipText = GettextCatalog.GetString("Show Successful Tests");
            toolbar.Add(buttonSuccess);

            buttonInconclusive                        = new ToggleButton();
            buttonInconclusive.Label                  = GettextCatalog.GetString("Inconclusive Tests");
            buttonInconclusive.Accessible.Name        = "TestResultsPad.InconclusiveTests";
            buttonInconclusive.Accessible.Description = GettextCatalog.GetString("Show the results for the inconclusive tests");
            buttonInconclusive.Active                 = true;
            buttonInconclusive.Image                  = new ImageView(TestStatusIcon.Inconclusive);
            buttonInconclusive.Image.Show();
            buttonInconclusive.Toggled    += new EventHandler(OnShowInconclusiveToggled);
            buttonInconclusive.TooltipText = GettextCatalog.GetString("Show Inconclusive Tests");
            toolbar.Add(buttonInconclusive);

            buttonFailures                        = new ToggleButton();
            buttonFailures.Label                  = GettextCatalog.GetString("Failed Tests");
            buttonFailures.Accessible.Name        = "TestResultsPad.FailedTests";
            buttonFailures.Accessible.Description = GettextCatalog.GetString("Show the results for the failed tests");
            buttonFailures.Active                 = true;
            buttonFailures.Image                  = new ImageView(TestStatusIcon.Failure);
            buttonFailures.Image.Show();
            buttonFailures.Toggled    += new EventHandler(OnShowFailuresToggled);
            buttonFailures.TooltipText = GettextCatalog.GetString("Show Failed Tests");
            toolbar.Add(buttonFailures);

            buttonIgnored                        = new ToggleButton();
            buttonIgnored.Label                  = GettextCatalog.GetString("Ignored Tests");
            buttonIgnored.Accessible.Name        = "TestResultsPad.IgnoredTests";
            buttonIgnored.Accessible.Description = GettextCatalog.GetString("Show the results for the ignored tests");
            buttonIgnored.Active                 = true;
            buttonIgnored.Image                  = new ImageView(TestStatusIcon.NotRun);
            buttonIgnored.Image.Show();
            buttonIgnored.Toggled    += new EventHandler(OnShowIgnoredToggled);
            buttonIgnored.TooltipText = GettextCatalog.GetString("Show Ignored Tests");
            toolbar.Add(buttonIgnored);

            buttonOutput                        = new ToggleButton();
            buttonOutput.Label                  = GettextCatalog.GetString("Output");
            buttonOutput.Accessible.Name        = "TestResultsPad.Output";
            buttonOutput.Accessible.Description = GettextCatalog.GetString("Show the test output");
            buttonOutput.Active                 = false;
            buttonOutput.Image                  = new ImageView(MonoDevelop.Ide.Gui.Stock.OutputIcon, IconSize.Menu);
            buttonOutput.Image.Show();
            buttonOutput.Toggled    += new EventHandler(OnShowOutputToggled);
            buttonOutput.TooltipText = GettextCatalog.GetString("Show Output");
            toolbar.Add(buttonOutput);

            toolbar.Add(new SeparatorToolItem());

            buttonRun                        = new Button();
            buttonRun.Label                  = GettextCatalog.GetString("Rerun Tests");
            buttonRun.Accessible.Name        = "TestResultsPad.Run";
            buttonRun.Accessible.Description = GettextCatalog.GetString("Start a test run and run all the tests");
            buttonRun.Image                  = new ImageView("md-execute-all", IconSize.Menu);
            buttonRun.Image.Show();
            buttonRun.Sensitive = false;
            toolbar.Add(buttonRun);

            buttonStop = new Button(new ImageView(Ide.Gui.Stock.Stop, Gtk.IconSize.Menu));
            buttonStop.Accessible.Name = "TestResultsPad.Stop";
            buttonStop.Accessible.SetTitle(GettextCatalog.GetString("Stop"));
            buttonStop.Accessible.Description = GettextCatalog.GetString("Stop the current test run");
            toolbar.Add(buttonStop);
            toolbar.ShowAll();

            buttonStop.Clicked += new EventHandler(OnStopClicked);
            buttonRun.Clicked  += new EventHandler(OnRunClicked);

            // Run panel

            DockItemToolbar runPanel = window.GetToolbar(DockPositionType.Bottom);

            infoSep = new VSeparator();

            resultLabel.UseMarkup    = true;
            infoCurrent.Ellipsize    = Pango.EllipsizeMode.Start;
            infoCurrent.WidthRequest = 0;
            runPanel.Add(resultLabel);
            runPanel.Add(progressBar);
            runPanel.Add(infoCurrent, true, 10);

            labels = new HBox(false, 10);

            infoLabel.UseMarkup = true;

            labels.PackStart(infoLabel, true, false, 0);

            runPanel.Add(new Gtk.Label(), true);
            runPanel.Add(labels);
            runPanel.Add(infoSep, false, 10);

            progressBar.HeightRequest = infoLabel.SizeRequest().Height;
            runPanel.ShowAll();
            progressBar.Hide();
            infoSep.Hide();
            resultSummary = new UnitTestResult();
            UpdateCounters();
        }
Ejemplo n.º 20
0
        void ShowTestResult(UnitTest test, UnitTestResult result)
        {
            if (result.IsSuccess)
            {
                if (!buttonSuccess.Active)
                {
                    return;
                }
                TreeIter testRow = failuresStore.AppendValues(TestStatusIcon.Success, Escape(test.FullName), test);
                failuresTreeView.ScrollToCell(failuresStore.GetPath(testRow), null, false, 0, 0);
            }
            if (result.IsFailure)
            {
                if (!buttonFailures.Active)
                {
                    return;
                }
                string   file       = test.SourceCodeLocation != null ? test.SourceCodeLocation.FileName + ":" + test.SourceCodeLocation.Line : null;
                TreeIter testRow    = failuresStore.AppendValues(TestStatusIcon.Failure, Escape(test.FullName), test, file);
                bool     hasMessage = !string.IsNullOrEmpty(result.Message);

                if (hasMessage)
                {
                    failuresStore.AppendValues(testRow, null, "<span font='" + FontService.MonospaceFontName + "'>" + Escape(result.Message) + "</span>", test, null, 0, ErrorMessage);
                }
                if (!string.IsNullOrEmpty(result.StackTrace))
                {
                    TreeIter row = testRow;
                    if (hasMessage)
                    {
                        row = failuresStore.AppendValues(testRow, null, GettextCatalog.GetString("Stack Trace"), test, null, 0, StackTrace);
                    }
                    AddStackTrace(row, result.StackTrace, test);
                }
                failuresTreeView.ScrollToCell(failuresStore.GetPath(testRow), null, false, 0, 0);
            }
            if (result.IsNotRun)
            {
                if (!buttonIgnored.Active)
                {
                    return;
                }
                TreeIter testRow = failuresStore.AppendValues(TestStatusIcon.NotRun, Escape(test.FullName), test);
                if (result.Message != null)
                {
                    failuresStore.AppendValues(testRow, null, Escape(result.Message), test);
                }
                failuresTreeView.ScrollToCell(failuresStore.GetPath(testRow), null, false, 0, 0);
            }
            if (result.IsInconclusive)
            {
                if (!buttonInconclusive.Active)
                {
                    return;
                }
                TreeIter testRow = failuresStore.AppendValues(TestStatusIcon.Inconclusive, Escape(test.FullName), test);
                if (result.Message != null)
                {
                    failuresStore.AppendValues(testRow, null, Escape(result.Message), test);
                }
                failuresTreeView.ScrollToCell(failuresStore.GetPath(testRow), null, false, 0, 0);
            }

            string   msg = GettextCatalog.GetString("Running {0} ...", test.FullName);
            TextIter it  = outputView.Buffer.EndIter;

            outIters [test] = it.Offset;
            outputView.Buffer.InsertWithTags(ref it, msg, bold);
            outputView.Buffer.Insert(ref it, "\n");
            if (result.ConsoleOutput != null)
            {
                outputView.Buffer.Insert(ref it, result.ConsoleOutput);
            }
            if (result.ConsoleError != null)
            {
                outputView.Buffer.Insert(ref it, result.ConsoleError);
            }
            outputView.ScrollMarkOnscreen(outputView.Buffer.InsertMark);
        }
Ejemplo n.º 21
0
		void ShowTestResult (UnitTest test, UnitTestResult result)
		{
			if (result.IsSuccess) {
				if (!buttonSuccess.Active)
					return;
				TreeIter testRow = failuresStore.AppendValues (TestStatusIcon.Success, Escape (test.FullName), test);
				failuresTreeView.ScrollToCell (failuresStore.GetPath (testRow), null, false, 0, 0);
			}
			if (result.IsFailure) {
				if (!buttonFailures.Active)
					return;
				string file = test.SourceCodeLocation != null ? test.SourceCodeLocation.FileName + ":" + test.SourceCodeLocation.Line : null;
				TreeIter testRow = failuresStore.AppendValues (TestStatusIcon.Failure, Escape (test.FullName), test, file);
				bool hasMessage = !string.IsNullOrEmpty (result.Message);

				if (hasMessage)
					failuresStore.AppendValues (testRow, null, "<span font='" + FontService.MonospaceFontName + "'>"+Escape (result.Message) + "</span>", test, null, 0, ErrorMessage);
				if (!string.IsNullOrEmpty (result.StackTrace)) {
					TreeIter row = testRow;
					if (hasMessage)
						row = failuresStore.AppendValues (testRow, null, GettextCatalog.GetString ("Stack Trace"), test, null, 0, StackTrace);
					AddStackTrace (row, result.StackTrace, test);
				}
				failuresTreeView.ScrollToCell (failuresStore.GetPath (testRow), null, false, 0, 0);
			}
			if (result.IsNotRun) {
				if (!buttonIgnored.Active)
					return;
				TreeIter testRow = failuresStore.AppendValues (TestStatusIcon.NotRun, Escape (test.FullName), test);
				if (result.Message != null)
					failuresStore.AppendValues (testRow, null, Escape (result.Message), test);
				failuresTreeView.ScrollToCell (failuresStore.GetPath (testRow), null, false, 0, 0);
			}
			if (result.IsInconclusive) {
				if (!buttonInconclusive.Active)
					return;
				TreeIter testRow = failuresStore.AppendValues (TestStatusIcon.Inconclusive, Escape (test.FullName), test);
				if (result.Message != null)
					failuresStore.AppendValues (testRow, null, Escape (result.Message), test);
				failuresTreeView.ScrollToCell (failuresStore.GetPath (testRow), null, false, 0, 0);
			}
			
			string msg = GettextCatalog.GetString ("Running {0} ...", test.FullName);
			TextIter it = outputView.Buffer.EndIter;
			outIters [test] = it.Offset;
			outputView.Buffer.InsertWithTags (ref it, msg, bold);
			outputView.Buffer.Insert (ref it, "\n");
			if (result.ConsoleOutput != null)
				outputView.Buffer.Insert (ref it, result.ConsoleOutput);
			if (result.ConsoleError != null)
				outputView.Buffer.Insert (ref it, result.ConsoleError);
			outputView.ScrollMarkOnscreen (outputView.Buffer.InsertMark);
		}
Ejemplo n.º 22
0
		public void Add (UnitTestResult res)
		{
			Time += res.Time;
			Passed += res.Passed;
			Errors += res.Errors;
			Failures += res.Failures;
			Ignored += res.Ignored;
			Inconclusive += res.Inconclusive;
			Skipped += res.Skipped;
		}
Ejemplo n.º 23
0
		public void EndTest (UnitTest test, UnitTestResult result)
		{
			Runtime.RunInMainThread (delegate {
				monitor.EndTest (test, result);
			});
		}
Ejemplo n.º 24
0
        public void Fill(UnitTest test)
        {
            serieFailed.Clear();
            serieSuccess.Clear();
            serieIgnored.Clear();
            serieTime.Clear();

            this.test = test;

            if (showLastTest)
            {
                if (timeScale)
                {
                    lastDateValue = DateTime.Now.Ticks;
                }
                else
                {
                    lastTestNumber = 0;
                }
            }

            UnitTestResult first = null;

            UnitTestResult[] results;
            UnitTestResult   lastResult = test.Results.GetLastResult(DateTime.Now);

            if (lastResult == null)
            {
                return;
            }

            if (timeScale)
            {
                DateTime startDate;
                if (showLastTest)
                {
                    startDate = lastResult.TestDate - currentSpan;
                    StartX    = startDate.Ticks;
                    EndX      = lastResult.TestDate.Ticks;
                    first     = test.Results.GetLastResult(startDate);
                    results   = test.Results.GetResults(startDate, lastResult.TestDate);
                }
                else
                {
                    DateTime endDate = new DateTime((long)lastDateValue);
                    startDate = endDate - currentSpan;
                    StartX    = (double)startDate.Ticks;
                    EndX      = (double)endDate.Ticks;
                    first     = test.Results.GetLastResult(startDate);
                    results   = test.Results.GetResults(startDate, lastResult.TestDate);
                }
                if (singleDayResult)
                {
                    first = test.Results.GetPreviousResult(new DateTime(startDate.Year, startDate.Month, startDate.Day));
                    ArrayList list = new ArrayList();
                    if (first != null)
                    {
                        list.Add(first);
                    }
                    for (int n = 0; n < results.Length - 1; n++)
                    {
                        DateTime d1 = results [n].TestDate;
                        DateTime d2 = results [n + 1].TestDate;
                        if (d1.Day != d2.Day || d1.Month != d2.Month || d1.Year != d2.Year)
                        {
                            list.Add(results [n]);
                        }
                    }
                    list.Add(results [results.Length - 1]);
                    results = (UnitTestResult[])list.ToArray(typeof(UnitTestResult));
                }

                if (resetCursors)
                {
                    SelectionEnd.Value = EndX;
                    if (results.Length > 1)
                    {
                        SelectionStart.Value = results [results.Length - 2].TestDate.Ticks;
                    }
                    else
                    {
                        SelectionStart.Value = EndX;
                    }
                    resetCursors = false;
                }
            }
            else
            {
                if (singleDayResult)
                {
                    ArrayList list = new ArrayList();
                    list.Add(lastResult);
                    while (list.Count < testCount + (int)lastTestNumber + 1)
                    {
                        UnitTestResult res = test.Results.GetPreviousResult(lastResult.TestDate);
                        if (res == null)
                        {
                            break;
                        }
                        if (res.TestDate.Day != lastResult.TestDate.Day || res.TestDate.Month != lastResult.TestDate.Month || res.TestDate.Year != lastResult.TestDate.Year)
                        {
                            list.Add(res);
                        }
                        lastResult = res;
                    }
                    results = (UnitTestResult[])list.ToArray(typeof(UnitTestResult));
                    Array.Reverse(results);
                }
                else
                {
                    results = test.Results.GetResultsToDate(DateTime.Now, testCount + (int)lastTestNumber + 1);
                }
                EndX   = lastTestNumber + testCount;
                StartX = lastTestNumber;

                if (resetCursors)
                {
                    SelectionStart.Value = StartX;
                    SelectionEnd.Value   = StartX + 1;
                    resetCursors         = false;
                }
            }


            currentResults = results;
            if (testRunAxis != null)
            {
                testRunAxis.CurrentResults = currentResults;
            }

            if (Type == TestChartType.Results)
            {
                if (first != null)
                {
                    double x = timeScale ? first.TestDate.Ticks : results.Length;
                    serieFailed.AddData(x, first.ErrorsAndFailures);
                    serieSuccess.AddData(x, first.Passed);
                    serieIgnored.AddData(x, first.TestsNotRun);
                }

                for (int n = 0; n < results.Length; n++)
                {
                    UnitTestResult res = results [n];
                    double         x   = timeScale ? res.TestDate.Ticks : results.Length - n - 1;
                    serieFailed.AddData(x, res.ErrorsAndFailures);
                    serieSuccess.AddData(x, res.Passed);
                    serieIgnored.AddData(x, res.TestsNotRun);
                }
            }
            else
            {
                if (first != null)
                {
                    double x = timeScale ? first.TestDate.Ticks : results.Length;
                    serieTime.AddData(x, first.Time.TotalMilliseconds);
                }
                for (int n = 0; n < results.Length; n++)
                {
                    UnitTestResult res = results [n];
                    double         x   = timeScale ? res.TestDate.Ticks : results.Length - n - 1;
                    serieTime.AddData(x, results [n].Time.TotalMilliseconds);
                }
            }
        }