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.º 2
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);
			}
		}
		UnitTest FindRootTest ()
		{
			if (!unitTestChecked) {
				unitTestFound = UnitTestService.FindRootTest (Project);
				unitTestChecked = true;
			}
			return unitTestFound;
		}
Ejemplo n.º 4
0
		public void OnTestSuiteChanged (object sender, EventArgs e)
		{
			if (rootTest != null) {
				rootTest = UnitTestService.SearchTest (rootTest.FullName);
				if (rootTest == null)
					buttonRun.Sensitive = false;
			}
		}
Ejemplo n.º 5
0
		ITreeNavigator FindTestNode (UnitTest t)
		{
			ITreeNavigator nav = TreeView.GetNodeAtObject (t);
			if (nav != null)
				return nav;
			if (t.Parent == null)
				return null;
				
			nav = FindTestNode (t.Parent);
			
			if (nav == null)
				return null;
				
			nav.MoveToFirstChild ();	// Make sure the children are created
			return TreeView.GetNodeAtObject (t);
		}
Ejemplo n.º 6
0
		void ClearDetails ()
		{
			chart.Clear ();
			detailLabel.Markup = "";
			detailsStore.Clear ();
			if (detailsTest != null)
				detailsTest.TestChanged -= OnDetailsTestChanged;
			detailsTest = null;
			detailsDate = DateTime.MinValue;
			detailsReferenceDate = DateTime.MinValue;
			detailsPad.Sensitive = false;
		}
		public UnitTestResult[] GetResultsToDate (string configuration, UnitTest test, DateTime endDate, int count)
		{
			ArrayList list = new ArrayList ();
			DateTime[] dates = GetStoreDates (configuration);
			
			for (int n = dates.Length - 1; n >= 0 && list.Count < count; n--) {
				if (dates [n] > endDate)
					continue;
				
				TestRecord root = GetRootRecord (configuration, dates [n]);
				if (root == null) continue;

				TestRecord tr = FindRecord (root, test.StoreRelativeName);
				if (tr != null && tr.Results != null) {
					for (int m = tr.Results.Count - 1; m >= 0 && list.Count < count; m--) {
						UnitTestResult res = (UnitTestResult) tr.Results [m];
						if (res.TestDate <= endDate)
							list.Add (res);
					}
				}
			}
			
			UnitTestResult[] array = (UnitTestResult[]) list.ToArray (typeof(UnitTestResult));
			Array.Reverse (array);
			return array;
		}
		public UnitTestResult GetNextResult (string configuration, UnitTest test, DateTime date)
		{
			DateTime currentDate = date;
			TestRecord root = GetRootRecord (configuration, currentDate);
			if (root == null)
				root = GetNextRootRecord (configuration, ref currentDate);
			
			while (root != null) {
				TestRecord tr = FindRecord (root, test.StoreRelativeName);
				if (tr != null && tr.Results != null) {
					foreach (UnitTestResult res in tr.Results) {
						if (res.TestDate > date)
							return res;
					}
				}
				root = GetNextRootRecord (configuration, ref currentDate);
			}
			return null;
		}
Ejemplo n.º 9
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);
                }
            }
        }
Ejemplo n.º 10
0
		public TestSession (UnitTest test, MonoDevelop.Projects.ExecutionContext context, TestResultsPad resultsPad, CancellationTokenSource cs)
		{
			this.test = test;
			if (context != null)
				this.context = new Projects.ExecutionContext (context.ExecutionHandler, new CustomConsoleFactory (context.ConsoleFactory, cs), context.ExecutionTarget);
			CancellationTokenSource = cs;
			this.monitor = new TestMonitor (resultsPad, CancellationTokenSource);
			this.resultsPad = resultsPad;
			resultsPad.InitializeTestRun (test, cs);
			Task = new Task ((Action)RunTests);
		}
Ejemplo n.º 11
0
 public void BeginTest(UnitTest test)
 {
     Runtime.RunInMainThread(delegate {
         monitor.BeginTest(test);
     });
 }
Ejemplo n.º 12
0
 public void EndTest(UnitTest test, UnitTestResult result)
 {
     Runtime.RunInMainThread(delegate {
         monitor.EndTest(test, result);
     });
 }
Ejemplo n.º 13
0
 public static void ResetResult(UnitTest test)
 {
     test?.ResetLastResult();
 }
Ejemplo n.º 14
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.º 15
0
 internal static Task RunTest(UnitTest test, MonoDevelop.Projects.ExecutionContext context, bool buildOwnerObject, bool checkCurrentRunOperation, CancellationTokenSource cs)
 {
     return(RunTests(new UnitTest [] { test }, context, buildOwnerObject, checkCurrentRunOperation, cs));
 }
Ejemplo n.º 16
0
        public static AsyncOperation RunTest(UnitTest test, MonoDevelop.Projects.ExecutionContext context, bool buildOwnerObject)
        {
            var cs = new CancellationTokenSource();

            return(new AsyncOperation(RunTests(new UnitTest [] { test }, context, buildOwnerObject, true, cs), cs));
        }
Ejemplo n.º 17
0
 public AsyncOperation RunTest(UnitTest test, IExecutionHandler mode)
 {
     return(RunTest(FindTestNode(test), mode, false));
 }
Ejemplo n.º 18
0
		void AddStackTrace (TreeIter row, string stackTrace, UnitTest test)
		{
			string[] stackLines = stackTrace.Replace ("\r", "").Split ('\n');
			foreach (string line in stackLines) {
				string fileName;
				int lineNumber;
				TryParseLocationFromStackTrace (line, out fileName, out lineNumber);
				failuresStore.AppendValues (row, null, Escape (line), test, fileName, lineNumber, StackTrace);
			}
		}
Ejemplo n.º 19
0
        protected void OnCopy()
        {
            UnitTest test = GetSelectedTest();

            if (test != null)
            {
                var last = test.GetLastResult();
                if (last == null)
                {
                    return;
                }

                Gtk.TreeModel foo;
                Gtk.TreeIter  iter;
                if (!failuresTreeView.Selection.GetSelected(out foo, out iter))
                {
                    return;
                }

                int type = (int)failuresStore.GetValue(iter, 5);

                var clipboard = Clipboard.Get(Gdk.Atom.Intern("CLIPBOARD", false));
                switch (type)
                {
                case ErrorMessage:
                    clipboard.Text = last.Message;
                    break;

                case StackTrace:
                    clipboard.Text = last.StackTrace;
                    break;

                default:
                    clipboard.Text = last.Message + Environment.NewLine + GettextCatalog.GetString("Stack trace:") + Environment.NewLine + last.StackTrace;
                    break;
                }
            }
            else
            {
                if (error == null)
                {
                    return;
                }
                var clipboard = Clipboard.Get(Gdk.Atom.Intern("CLIPBOARD", false));

                Gtk.TreeModel foo;
                Gtk.TreeIter  iter;
                if (!failuresTreeView.Selection.GetSelected(out foo, out iter))
                {
                    return;
                }

                int type = (int)failuresStore.GetValue(iter, 5);

                switch (type)
                {
                case ErrorMessage:
                    clipboard.Text = error.Message;
                    break;

                case StackTrace:
                    clipboard.Text = error.StackTrace;
                    break;

                default:
                    clipboard.Text = error.Message + Environment.NewLine + GettextCatalog.GetString("Stack trace:") + Environment.NewLine + error.StackTrace;
                    break;
                }
            }
        }
Ejemplo n.º 20
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.º 21
0
        protected void OnUpdateSelectTestInTree(CommandInfo info)
        {
            UnitTest test = GetSelectedTest();

            info.Enabled = test != null;
        }
Ejemplo n.º 22
0
		static UnitTest SearchTestById (UnitTest test, string id)
		{
			if (test == null)
				return null;
			if (test.TestId == id)
				return test;

			UnitTestGroup group = test as UnitTestGroup;
			if (group != null)  {
				foreach (UnitTest t in group.Tests) {
					UnitTest result = SearchTestById (t, id);
					if (result != null)
						return result;
				}
			}
			return null;
		}
Ejemplo n.º 23
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.º 24
0
        protected void OnUpdateGoToFailure(CommandInfo info)
        {
            UnitTest test = CurrentNode.DataItem as UnitTest;

            info.Enabled = IsGoToFailureEnabled(test);
        }
Ejemplo n.º 25
0
 void ITestProgressMonitor.BeginTest(UnitTest test)
 {
     infoCurrent.Text   = GettextCatalog.GetString("Running ") + test.FullName;
     infoCurrent.Xalign = 0;
 }
Ejemplo n.º 26
0
 internal void SetParent(UnitTest t)
 {
     parent = t;
 }
Ejemplo n.º 27
0
 protected virtual UnitTestResult OnRunChildTest(UnitTest test, TestContext testContext)
 {
     return(test.Run(testContext));
 }
Ejemplo n.º 28
0
		public void SelectTest (UnitTest t)
		{
			ITreeNavigator node = FindTestNode (t);
			if (node != null) {
				node.ExpandToNode ();
				node.Selected = true;
			}
		}
Ejemplo n.º 29
0
 internal UnitTestResultsStore(UnitTest test, IResultsStore store)
 {
     this.test  = test;
     this.store = store;
 }
Ejemplo n.º 30
0
		public AsyncOperation RunTest (UnitTest test, IExecutionHandler mode)
		{
			return RunTest (FindTestNode (test), mode, false);
		}
Ejemplo n.º 31
0
 void TestSuiteChanged(object sender, System.EventArgs e)
 {
     unitTestChecked = false;
     unitTestFound   = null;
 }
Ejemplo n.º 32
0
		void FillDetails (UnitTest test, bool selectInTree)
		{
			if (!detailsPad.Visible)
				return;

			detailsPad.Sensitive = true;
			
			if (detailsTest != null)
				detailsTest.TestChanged -= OnDetailsTestChanged;
			
			if (detailsTest != test) {
				detailsTest = test;
				if (selectInTree)
					SelectTest (test);
				testNavigationHistory.Add (test);
				if (testNavigationHistory.Count > 50)
					testNavigationHistory.RemoveAt (0);
			}
			detailsTest.TestChanged += OnDetailsTestChanged;
			
			if (test is UnitTestGroup) {
				infoBook.HidePage (TestResultPage);
				infoBook.HidePage (TestOutputPage);
				infoBook.ShowPage (TestSummaryPage);
				infoBook.ShowPage (TestRegressionsPage);
				infoBook.ShowPage (TestFailuresPage);
			} else {
				infoBook.HidePage (TestSummaryPage);
				infoBook.HidePage (TestRegressionsPage);
				infoBook.HidePage (TestFailuresPage);
				infoBook.ShowPage (TestResultPage);
				infoBook.ShowPage (TestOutputPage);
			}
			detailLabel.Markup = "<b>" + test.Name + "</b>";
			detailsDate = DateTime.MinValue;
			detailsReferenceDate = DateTime.MinValue;
			chart.Fill (test);
			infoBook.Reset ();
		}
Ejemplo n.º 33
0
		public void BeginTest (UnitTest test)
		{
			Runtime.RunInMainThread (delegate {
				monitor.BeginTest (test);
			});
		}
Ejemplo n.º 34
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.º 35
0
		public static AsyncOperation RunTest (UnitTest test, MonoDevelop.Projects.ExecutionContext context)
		{
			var result = RunTest (test, context, IdeApp.Preferences.BuildBeforeRunningTests);
			result.Task.ContinueWith (t => OnTestSessionCompleted (), TaskScheduler.FromCurrentSynchronizationContext ());
			return result;
		}
Ejemplo n.º 36
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.º 37
0
		internal static async Task RunTest (UnitTest test, MonoDevelop.Projects.ExecutionContext context, bool buildOwnerObject, bool checkCurrentRunOperation, CancellationTokenSource cs)
		{
			string testName = test.FullName;
			
			if (buildOwnerObject) {
				IBuildTarget bt = test.OwnerObject as IBuildTarget;
				if (bt != null) {
					if (!IdeApp.ProjectOperations.CurrentRunOperation.IsCompleted) {
						MonoDevelop.Ide.Commands.StopHandler.StopBuildOperations ();
						await IdeApp.ProjectOperations.CurrentRunOperation.Task;
					}
	
					var res = await IdeApp.ProjectOperations.Build (bt, cs.Token).Task;
					if (res.HasErrors)
						return;

					await RefreshTests (cs.Token);
					test = SearchTest (testName);
					if (test != null)
						await RunTest (test, context, false, checkCurrentRunOperation, cs);
					return;
				}
			}
			
			if (checkCurrentRunOperation && !IdeApp.ProjectOperations.ConfirmExecutionOperation ())
				return;
			
			Pad resultsPad = IdeApp.Workbench.GetPad <TestResultsPad>();
			if (resultsPad == null) {
				resultsPad = IdeApp.Workbench.ShowPad (new TestResultsPad (), "MonoDevelop.UnitTesting.TestResultsPad", GettextCatalog.GetString ("Test results"), "Bottom", "md-solution");
			}
			
			// Make the pad sticky while the tests are runnig, so the results pad is always visible (even if minimized)
			// That's required since when running in debug mode, the layout is automatically switched to debug.
			
			resultsPad.Sticky = true;
			resultsPad.BringToFront ();
			
			TestSession session = new TestSession (test, context, (TestResultsPad) resultsPad.Content, cs);
			
			OnTestSessionStarting (new TestSessionEventArgs { Session = session, Test = test });

			if (checkCurrentRunOperation)
				IdeApp.ProjectOperations.CurrentRunOperation = session;
			
			try {
				await session.Start ();
			} finally {
				resultsPad.Sticky = false;
			}
		}
Ejemplo n.º 38
0
		void ITestProgressMonitor.BeginTest (UnitTest test)
		{
			infoCurrent.Text = GettextCatalog.GetString ("Running ") + test.FullName;
			infoCurrent.Xalign = 0;
		}
Ejemplo n.º 39
0
 public new void Clear()
 {
     base.Clear();
     test = null;
 }
Ejemplo n.º 40
0
		public void EndTest (UnitTest test, UnitTestResult result)
		{
			Runtime.RunInMainThread (delegate {
				monitor.EndTest (test, result);
			});
		}
		void TestSuiteChanged (object sender, System.EventArgs e)
		{
			unitTestChecked = false;
			unitTestFound = null;
		}
Ejemplo n.º 42
0
		public static AsyncOperation RunTest (UnitTest test, MonoDevelop.Projects.ExecutionContext context, bool buildOwnerObject)
		{
			var cs = new CancellationTokenSource ();
			return new AsyncOperation (RunTest (test, context, buildOwnerObject, true, cs), cs);
		}
		public UnitTestResult GetPreviousResult (string configuration, UnitTest test, DateTime date)
		{
			DateTime currentDate = date;
			TestRecord root = GetRootRecord (configuration, currentDate);
			if (root == null)
				root = GetPreviousRootRecord (configuration, ref currentDate);
			
			while (root != null) {
				TestRecord tr = FindRecord (root, test.StoreRelativeName);
				if (tr != null && tr.Results != null) {
					for (int n = tr.Results.Count - 1; n >= 0; n--) {
						UnitTestResult res = (UnitTestResult) tr.Results [n];
						if (res.TestDate < date)
							return res;
					}
				}
				root = GetPreviousRootRecord (configuration, ref currentDate);
			}
			return null;
		}
Ejemplo n.º 44
0
		static UnitTest SearchTest (UnitTest test, string fullName)
		{
			if (test == null)
				return null;
			if (test.FullName == fullName)
				return test;

			UnitTestGroup group = test as UnitTestGroup;
			if (group != null)  {
				foreach (UnitTest t in group.Tests) {
					UnitTest result = SearchTest (t, fullName);
					if (result != null)
						return result;
				}
			}
			return null;
		}
		public UnitTestResult GetLastResult (string configuration, UnitTest test, DateTime date)
		{
			return GetPreviousResult (configuration, test, date.AddTicks (1));
		}
Ejemplo n.º 46
0
		public static void ResetResult (UnitTest test)
		{
			if (test == null)
				return;
			test.ResetLastResult ();
			UnitTestGroup group = test as UnitTestGroup;
			if (group == null) 
				return;
			foreach (UnitTest t in new List<UnitTest> (group.Tests))
				ResetResult (t);
		}
		public UnitTestResult[] GetResults (string configuration, UnitTest test, DateTime startDate, DateTime endDate)
		{
			ArrayList list = new ArrayList ();
			DateTime firstDay = new DateTime (startDate.Year, startDate.Month, startDate.Day);
			
			DateTime[] dates = GetStoreDates (configuration);
			
			foreach (DateTime date in dates) {
				if (date < firstDay)
					continue;
				if (date > endDate)
					break;
				
				TestRecord root = GetRootRecord (configuration, date);
				if (root == null) continue;

				TestRecord tr = FindRecord (root, test.StoreRelativeName);
				if (tr != null && tr.Results != null) {
					foreach (UnitTestResult res in tr.Results) {
						if (res.TestDate >= startDate && res.TestDate <= endDate)
							list.Add (res);
					}
				}
			}
			
			return (UnitTestResult[]) list.ToArray (typeof(UnitTestResult));
		}
Ejemplo n.º 48
0
		bool IsGoToFailureEnabled (UnitTest test)
		{
			if (test.SourceCodeLocation == null || test is UnitTestGroup)
				return false;

			UnitTestResult res = test.GetLastResult ();
			return res != null && res.IsFailure;
		}
Ejemplo n.º 49
0
        protected void OnUpdateRunTest(CommandInfo info)
        {
            UnitTest test = CurrentNode.DataItem as UnitTest;

            info.Enabled = test.SourceCodeLocation != null;
        }