internal UnitTestResult RunUnitTest (UnitTest test, string suiteName, string pathName, string testName, TestContext testContext)
		{
			var runnerExe = GetCustomConsoleRunnerCommand ();
			if (runnerExe != null)
				return RunWithConsoleRunner (runnerExe, test, suiteName, pathName, testName, testContext);

			ExternalTestRunner runner = (ExternalTestRunner)Runtime.ProcessService.CreateExternalProcessObject (typeof(ExternalTestRunner), testContext.ExecutionContext, UserAssemblyPaths);
			LocalTestMonitor localMonitor = new LocalTestMonitor (testContext, test, suiteName, testName != null);

			ITestFilter filter = null;
			if (test != null) {
				if (test is UnitTestGroup) {
					var categoryOptions = (NUnitCategoryOptions) test.GetOptions (typeof(NUnitCategoryOptions));
					if (categoryOptions.EnableFilter && categoryOptions.Categories.Count > 0) {
						string[] cats = new string [categoryOptions.Categories.Count];
						categoryOptions.Categories.CopyTo (cats, 0);
						filter = new CategoryFilter (cats);
						if (categoryOptions.Exclude)
							filter = new NotFilter (filter);
					} else {
						filter = new TestNameFilter (CollectTests ((UnitTestGroup)test));
					}
				} else {
					filter = new TestNameFilter (test.TestId);
				}
			}

			RunData rd = new RunData ();
			rd.Runner = runner;
			rd.Test = this;
			rd.LocalMonitor = localMonitor;
			testContext.Monitor.CancelRequested += new TestHandler (rd.Cancel);

			UnitTestResult result;
			var crashLogFile = Path.GetTempFileName ();

			try {
				if (string.IsNullOrEmpty (AssemblyPath)) {
					string msg = GettextCatalog.GetString ("Could not get a valid path to the assembly. There may be a conflict in the project configurations.");
					throw new Exception (msg);
				}
				System.Runtime.Remoting.RemotingServices.Marshal (localMonitor, null, typeof (IRemoteEventListener));

				string testRunnerAssembly, testRunnerType;
				GetCustomTestRunner (out testRunnerAssembly, out testRunnerType);

				result = runner.Run (localMonitor, filter, AssemblyPath, "", new List<string> (SupportAssemblies), testRunnerType, testRunnerAssembly, crashLogFile);
				if (testName != null)
					result = localMonitor.SingleTestResult;
				
				ReportCrash (testContext, crashLogFile);
				
			} catch (Exception ex) {
				if (ReportCrash (testContext, crashLogFile)) {
					result = UnitTestResult.CreateFailure (GettextCatalog.GetString ("Unhandled exception"), null);
				}
				else if (!localMonitor.Canceled) {
					LoggingService.LogError (ex.ToString ());
					if (localMonitor.RunningTest != null) {
						RuntimeErrorCleanup (testContext, localMonitor.RunningTest, ex);
					} else {
						testContext.Monitor.ReportRuntimeError (null, ex);
						throw;
					}
					result = UnitTestResult.CreateFailure (ex);
				} else {
					result = UnitTestResult.CreateFailure (GettextCatalog.GetString ("Canceled"), null);
				}
			} finally {
				File.Delete (crashLogFile);
				testContext.Monitor.CancelRequested -= new TestHandler (rd.Cancel);
				runner.Dispose ();
				System.Runtime.Remoting.RemotingServices.Disconnect (localMonitor);
			}
			
			return result;
		}
		public XUnitExecutionSession (UnitTest unitTest, bool reportToMonitor)
		{
			this.reportToMonitor = reportToMonitor;
			this.unitTest = unitTest;
			result = new UnitTestResult ();
			childSessions = new List<XUnitExecutionSession> ();
		}
		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);
		}
        public UnitTestOptionsDialog(Gtk.Window parent, UnitTest test)
            : base(parent, null, null)
        {
            IAddInTreeNode node = AddInTreeSingleton.AddInTree.GetTreeNode("/SharpDevelop/Workbench/UnitTestOptions/GeneralOptions");
            configurationNode = AddInTreeSingleton.AddInTree.GetTreeNode("/SharpDevelop/Workbench/UnitTestOptions/ConfigurationProperties");

            this.test = test;
            this.Title = GettextCatalog.GetString ("Unit Test Options");

            properties = new DefaultProperties();
            properties.SetProperty ("UnitTest", test);
            AddNodes (properties, Gtk.TreeIter.Zero, node.BuildChildItems (this));
            SelectFirstNode ();
        }
		public NUnitOptionsWidget (Properties customizationObject)
		{
			Build ();
			test =  ((Properties)customizationObject).Get<UnitTest> ("UnitTest");
			config =  ((Properties)customizationObject).Get<string> ("Config");
			options = localOptions = (NUnitCategoryOptions) test.GetOptions (typeof(NUnitCategoryOptions), config);
			
			store = new TreeStore (typeof(string));
			categoryTree.Model = store;
			categoryTree.HeadersVisible = false;
			
			CellRendererText tr = new CellRendererText ();
			tr.Editable = true;
			tr.Edited += new EditedHandler (OnCategoryEdited);
			textColumn = new TreeViewColumn ();
			textColumn.Title = GettextCatalog.GetString ("Category");
			textColumn.PackStart (tr, false);
			textColumn.AddAttribute (tr, "text", 0);
			textColumn.Expand = true;
			categoryTree.AppendColumn (textColumn);
			
			if (test.Parent != null)
				useParentCheck.Active = !test.HasOptions (typeof(NUnitCategoryOptions), config);
			else {
				useParentCheck.Active = false;
				useParentCheck.Sensitive = false;
			}
			
			if (!options.EnableFilter)
				noFilterRadio.Active = true;
			else if (options.Exclude)
				excludeRadio.Active = true;
			else
				includeRadio.Active = true;

			Fill ();
			
			noFilterRadio.Toggled += new EventHandler (OnFilterToggled);
			includeRadio.Toggled += new EventHandler (OnFilterToggled);
			excludeRadio.Toggled += new EventHandler (OnFilterToggled);
			useParentCheck.Toggled += new EventHandler (OnToggledUseParent);
			addButton.Clicked += new EventHandler (OnAddCategory);
			removeButton.Clicked += new EventHandler (OnRemoveCategory);
		}
Exemplo n.º 6
0
		public UnitTestOptionsDialog (Gtk.Window parent, Properties properties) : base (parent, properties, "/MonoDevelop/NUnit/UnitTestOptions/GeneralOptions", false)
		{
			this.Title = GettextCatalog.GetString ("Unit Test Options");
		
			test = properties.Get<UnitTest>("UnitTest");
			configurationNode = AddinManager.GetExtensionNode("/MonoDevelop/NUnit/UnitTestOptions/ConfigurationOptions");
			
			TreeIter iter;
			if (store.GetIterFirst (out iter)) {
				OptionsDialogSection section = store.GetValue (iter, 0) as OptionsDialogSection;
				
				if (section != null && section.Id == "Configurations") {
					FillConfigurations (iter);
				}
			}
			ExpandCategories ();
			if (firstSection != null)
				ShowPage (firstSection);
		}
		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;
		}
Exemplo n.º 8
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);
		}
Exemplo n.º 9
0
 public UnitTestResult GetLastResult(string configuration, UnitTest test, DateTime date)
 {
     return(GetPreviousResult(configuration, test, date.AddTicks(1)));
 }
Exemplo n.º 10
0
 public void BeginTest(UnitTest test)
 {
     DispatchService.GuiDispatch(delegate {
         monitor.BeginTest(test);
     });
 }
		public UnitTestResult GetLastResult (string configuration, UnitTest test, DateTime date)
		{
			return GetPreviousResult (configuration, test, date.AddTicks (1));
		}
        internal UnitTestResult RunUnitTest(UnitTest test, string suiteName, TestContext testContext)
        {
            ExternalTestRunner runner = (ExternalTestRunner) Runtime.ProcessService.CreateExternalProcessObject (typeof(ExternalTestRunner), false);
            LocalTestMonitor localMonitor = new LocalTestMonitor (testContext, runner, test, suiteName);

            IFilter filter = null;

            NUnitCategoryOptions categoryOptions = (NUnitCategoryOptions) test.GetOptions (typeof(NUnitCategoryOptions));
            if (categoryOptions.EnableFilter && categoryOptions.Categories.Count > 0) {
                string[] cats = new string [categoryOptions.Categories.Count];
                categoryOptions.Categories.CopyTo (cats, 0);
                filter = new CategoryFilter (cats, categoryOptions.Exclude);
            }

            RunData rd = new RunData ();
            rd.Runner = runner;
            rd.Test = this;
            testContext.Monitor.CancelRequested += new TestHandler (rd.Cancel);

            UnitTestResult result;

            try {
                TestResult res = runner.Run (localMonitor, filter, AssemblyPath, suiteName, null);
                result = localMonitor.GetLocalTestResult (res);
            } catch (Exception ex) {
                Console.WriteLine (ex);
                if (localMonitor.RunningTest != null) {
                    RuntimeErrorCleanup (testContext, localMonitor.RunningTest, ex);
                } else {
                    testContext.Monitor.ReportRuntimeError (null, ex);
                    throw ex;
                }
                result = UnitTestResult.CreateFailure (ex);
            } finally {
                testContext.Monitor.CancelRequested -= new TestHandler (rd.Cancel);
                runner.Dispose ();
            }

            return result;
        }
Exemplo n.º 13
0
 public TestSession(UnitTest test, IExecutionHandler context, TestResultsPad resultsPad)
 {
     this.test    = test;
     this.context = context;
     this.monitor = new TestMonitor(resultsPad);
 }
Exemplo n.º 14
0
		public IAsyncOperation RunTest (UnitTest test, IExecutionHandler mode)
		{
			return RunTest (FindTestNode (test), mode, false);
		}
Exemplo n.º 15
0
        UnitTestResult RunWithConsoleRunner(ProcessExecutionCommand cmd, UnitTest test, string suiteName, string pathName, string testName, TestContext testContext)
        {
            var          outFile = Path.GetTempFileName();
            LocalConsole cons    = new LocalConsole();

            try {
                LocalTestMonitor localMonitor = new LocalTestMonitor(testContext, test, suiteName, testName != null);

                if (!string.IsNullOrEmpty(cmd.Arguments))
                {
                    cmd.Arguments += " ";
                }
                cmd.Arguments += "\"-xml=" + outFile + "\" " + AssemblyPath;

                bool automaticUpdates = cmd.Command.Contains("GuiUnit") || (cmd.Command.Contains("mdtool.exe") && cmd.Arguments.Contains("run-md-tests"));
                if (!string.IsNullOrEmpty(testName))
                {
                    cmd.Arguments += " -run=" + suiteName + "." + testName;
                }
                else if (!string.IsNullOrEmpty(suiteName))
                {
                    cmd.Arguments += " -run=" + suiteName;
                }
                if (automaticUpdates)
                {
                    var tcpListener = new MonoDevelop.NUnit.External.TcpTestListener(localMonitor);
                    cmd.Arguments += " -port=" + tcpListener.Port;
                }
                var p = testContext.ExecutionContext.Execute(cmd, cons);

                testContext.Monitor.CancelRequested += p.Cancel;
                if (testContext.Monitor.IsCancelRequested)
                {
                    p.Cancel();
                }
                p.WaitForCompleted();

                if (new FileInfo(outFile).Length == 0)
                {
                    throw new Exception("Command failed");
                }

                XDocument doc = XDocument.Load(outFile);

                if (doc.Root != null)
                {
                    if (automaticUpdates)
                    {
                        DispatchService.GuiDispatch(delegate {
                            testContext.ResultsPad.InitializeTestRun(test);
                        });
                    }

                    var root = doc.Root.Elements("test-suite").FirstOrDefault();
                    if (root != null)
                    {
                        cons.SetDone();
                        var ot = cons.Out.ReadToEnd();
                        var et = cons.Error.ReadToEnd();
                        testContext.Monitor.WriteGlobalLog(ot);
                        if (!string.IsNullOrEmpty(et))
                        {
                            testContext.Monitor.WriteGlobalLog("ERROR:\n");
                            testContext.Monitor.WriteGlobalLog(et);
                        }

                        bool macunitStyle = doc.Root.Element("environment") != null && doc.Root.Element("environment").Attribute("macunit-version") != null;
                        return(ReportXmlResult(localMonitor, root, "", macunitStyle));
                    }
                }
                throw new Exception("Test results could not be parsed.");
            } catch (Exception ex) {
                cons.SetDone();
                var ot = cons.Out.ReadToEnd();
                var et = cons.Error.ReadToEnd();
                testContext.Monitor.WriteGlobalLog(ot);
                if (!string.IsNullOrEmpty(et))
                {
                    testContext.Monitor.WriteGlobalLog("ERROR:\n");
                    testContext.Monitor.WriteGlobalLog(et);
                }
                testContext.Monitor.ReportRuntimeError("Test execution failed.\n" + ot + "\n" + et, ex);
                return(UnitTestResult.CreateIgnored("Test execution failed"));
            } finally {
                File.Delete(outFile);
            }
        }
Exemplo n.º 16
0
        protected void OnUpdateGoToFailure(CommandInfo info)
        {
            UnitTest test = CurrentNode.DataItem as UnitTest;

            info.Enabled = IsGoToFailureEnabled(test);
        }
Exemplo n.º 17
0
        protected void OnUpdateRunTest(CommandInfo info)
        {
            UnitTest test = CurrentNode.DataItem as UnitTest;

            info.Enabled = test.SourceCodeLocation != null;
        }
Exemplo n.º 18
0
 void ITestProgressMonitor.EndTest(UnitTest test, UnitTestResult result)
 {
     monitor.EndTest(test, result);
 }
Exemplo n.º 19
0
 void ITestProgressMonitor.BeginTest(UnitTest test)
 {
     monitor.BeginTest(test);
 }
Exemplo n.º 20
0
        public IAsyncOperation RunTest(UnitTest test, IExecutionHandler context, bool buildOwnerObject)
        {
            string testName = test.FullName;

            if (buildOwnerObject)
            {
                IBuildTarget bt = test.OwnerObject as IBuildTarget;
                if (bt != null && bt.NeedsBuilding(IdeApp.Workspace.ActiveConfiguration))
                {
                    if (!IdeApp.ProjectOperations.CurrentRunOperation.IsCompleted)
                    {
                        MonoDevelop.Ide.Commands.StopHandler.StopBuildOperations();
                        IdeApp.ProjectOperations.CurrentRunOperation.WaitForCompleted();
                    }

                    AsyncOperation retOper = new AsyncOperation();

                    IAsyncOperation op = IdeApp.ProjectOperations.Build(bt);
                    retOper.TrackOperation(op, false);

                    op.Completed += delegate {
                        // The completed event of the build operation is run in the gui thread,
                        // so we need a new thread, because refreshing must be async
                        System.Threading.ThreadPool.QueueUserWorkItem(delegate {
                            if (op.Success)
                            {
                                RefreshTests();
                                test = SearchTest(testName);
                                if (test != null)
                                {
                                    Gtk.Application.Invoke(delegate {
                                        // RunTest must run in the gui thread
                                        retOper.TrackOperation(RunTest(test, context, false), true);
                                    });
                                }
                                else
                                {
                                    retOper.SetCompleted(false);
                                }
                            }
                        });
                    };

                    return(retOper);
                }
            }

            if (!IdeApp.ProjectOperations.ConfirmExecutionOperation())
            {
                return(NullProcessAsyncOperation.Failure);
            }

            Pad resultsPad = IdeApp.Workbench.GetPad <TestResultsPad>();

            if (resultsPad == null)
            {
                resultsPad = IdeApp.Workbench.ShowPad(new TestResultsPad(), "MonoDevelop.NUnit.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);

            session.Completed += delegate {
                Gtk.Application.Invoke(delegate {
                    resultsPad.Sticky = false;
                });
            };

            session.Start();

            IdeApp.ProjectOperations.CurrentRunOperation = session;

            return(session);
        }
Exemplo n.º 21
0
 internal void SetParent(UnitTest t)
 {
     parent = t;
 }
Exemplo n.º 22
0
		void ITestProgressMonitor.BeginTest (UnitTest test)
		{
			monitor.BeginTest (test);
		}
Exemplo n.º 23
0
		public void SelectTest (UnitTest t)
		{
			ITreeNavigator node = FindTestNode (t);
			if (node != null) {
				node.ExpandToNode ();
				node.Selected = true;
			}
		}
Exemplo n.º 24
0
 public AsyncOperation RunTest(UnitTest test, IExecutionHandler mode)
 {
     return(RunTest(FindTestNode(test), mode, false));
 }
Exemplo n.º 25
0
		void FillDetails (UnitTest test, bool selectInTree)
		{
			if (!detailsPad.Visible)
				return;

			detailsPad.Sensitive = true;
			
			if (detailsTest != null)
				detailsTest.TestChanged -= testChangedHandler;
			
			if (detailsTest != test) {
				detailsTest = test;
				if (selectInTree)
					SelectTest (test);
				testNavigationHistory.Add (test);
				if (testNavigationHistory.Count > 50)
					testNavigationHistory.RemoveAt (0);
			}
			detailsTest.TestChanged += testChangedHandler;
			
			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 ();
		}
Exemplo n.º 26
0
        protected void OnUpdateSelectTestInTree(CommandInfo info)
        {
            UnitTest test = GetSelectedTest();

            info.Enabled = test != null;
        }
		protected virtual UnitTestResult OnRunChildTest (UnitTest test, TestContext testContext)
		{
			return test.Run (testContext);
		}
Exemplo n.º 28
0
        protected void OnUpdateRunTest(CommandInfo info)
        {
            UnitTest test = GetSelectedTest();

            info.Enabled = test != null && test.SourceCodeLocation != null;
        }
 void ClearRunningStatus(UnitTest t)
 {
     t.Status = TestStatus.Ready;
     UnitTestGroup group = t as UnitTestGroup;
     if (group == null) return;
     foreach (UnitTest ct in group.Tests)
         ClearRunningStatus (ct);
 }
Exemplo n.º 30
0
        void ShowTestResult(UnitTest test, UnitTestResult result)
        {
            if (result.IsSuccess)
            {
                if (!buttonSuccess.Active)
                {
                    return;
                }
                TreeIter testRow = failuresStore.AppendValues(CircleImage.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(CircleImage.Failure, Escape(test.FullName), test, file);
                bool     hasMessage = result.Message != null && result.Message.Length > 0;
                if (hasMessage)
                {
                    failuresStore.AppendValues(testRow, null, Escape(result.Message), test);
                }
                if (result.StackTrace != null && result.StackTrace.Length > 0)
                {
                    TreeIter row = testRow;
                    if (hasMessage)
                    {
                        row = failuresStore.AppendValues(testRow, null, GettextCatalog.GetString("Stack Trace"), test);
                    }
                    AddStackTrace(row, result.StackTrace, test);
                }
                failuresTreeView.ScrollToCell(failuresStore.GetPath(testRow), null, false, 0, 0);
            }
            if (result.IsIgnored)
            {
                if (!buttonIgnored.Active)
                {
                    return;
                }
                TreeIter testRow = failuresStore.AppendValues(CircleImage.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);
            }

            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);
        }
		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;
		}
Exemplo n.º 32
0
		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;
		}
Exemplo n.º 33
0
 void ITestProgressMonitor.BeginTest(UnitTest test)
 {
     infoCurrent.Text   = GettextCatalog.GetString("Running ") + test.FullName;
     infoCurrent.Xalign = 0;
 }
Exemplo n.º 34
0
 public void EndTest(UnitTest test, UnitTestResult result)
 {
     DispatchService.GuiDispatch(delegate {
         monitor.EndTest(test, result);
     });
 }
Exemplo n.º 35
0
		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;
		}
Exemplo n.º 36
0
 public void InitializeTestRun(UnitTest test)
 {
     pad.InitializeTestRun(test);
 }
Exemplo n.º 37
0
		public static void ShowOptionsDialog (UnitTest test)
		{
			Properties properties = new Properties ();
			properties.Set ("UnitTest", test);
			using (var dlg = new UnitTestOptionsDialog (IdeApp.Workbench.RootWindow, properties))
				MessageService.ShowCustomDialog (dlg);
		}
Exemplo n.º 38
0
 public void BeginTest(UnitTest test)
 {
     monitor.BeginTest(test);
 }
Exemplo n.º 39
0
		public TestSession (UnitTest test, IExecutionHandler context, TestResultsPad resultsPad)
		{
			this.test = test;
			this.context = context;
			this.monitor = new TestMonitor (resultsPad);
			this.resultsPad = resultsPad;
			resultsPad.InitializeTestRun (test);
		}
Exemplo n.º 40
0
 public void EndTest(UnitTest test, UnitTestResult result)
 {
     monitor.EndTest(test, result);
 }
Exemplo n.º 41
0
		void ITestProgressMonitor.EndTest (UnitTest test, UnitTestResult result)
		{
			monitor.EndTest (test, result);
		}
 internal UnitTestResultsStore(UnitTest test, IResultsStore store)
 {
     this.test  = test;
     this.store = store;
 }
Exemplo n.º 43
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);
		}
Exemplo n.º 44
0
        internal UnitTestResult RunUnitTest(UnitTest test, string suiteName, string pathName, string testName, TestContext testContext)
        {
            var runnerExe = GetCustomConsoleRunnerCommand();

            if (runnerExe != null)
            {
                return(RunWithConsoleRunner(runnerExe, test, suiteName, pathName, testName, testContext));
            }
            var console = IdeApp.Workbench?.ProgressMonitors.ConsoleFactory.CreateConsole();
            ExternalTestRunner runner       = (ExternalTestRunner)Runtime.ProcessService.CreateExternalProcessObject(typeof(ExternalTestRunner), testContext.ExecutionContext, UserAssemblyPaths, console);
            LocalTestMonitor   localMonitor = new LocalTestMonitor(testContext, test, suiteName, testName != null);

            ITestFilter filter = null;

            if (test != null)
            {
                if (test is UnitTestGroup)
                {
                    filter = new TestNameFilter(CollectTests((UnitTestGroup)test));
                }
                else
                {
                    filter = new TestNameFilter(test.TestId);
                }
            }

            RunData rd = new RunData();

            rd.Runner       = runner;
            rd.Test         = this;
            rd.LocalMonitor = localMonitor;
            testContext.Monitor.CancelRequested += new TestHandler(rd.Cancel);

            UnitTestResult result;
            var            crashLogFile = Path.GetTempFileName();

            try {
                if (string.IsNullOrEmpty(AssemblyPath))
                {
                    string msg = GettextCatalog.GetString("Could not get a valid path to the assembly. There may be a conflict in the project configurations.");
                    throw new Exception(msg);
                }
                System.Runtime.Remoting.RemotingServices.Marshal(localMonitor, null, typeof(IRemoteEventListener));

                string testRunnerAssembly, testRunnerType;
                GetCustomTestRunner(out testRunnerAssembly, out testRunnerType);

                result = runner.Run(localMonitor, filter, AssemblyPath, "", new List <string> (SupportAssemblies), testRunnerType, testRunnerAssembly, crashLogFile);
                if (testName != null)
                {
                    result = localMonitor.SingleTestResult;
                }

                ReportCrash(testContext, crashLogFile);
            } catch (Exception ex) {
                if (ReportCrash(testContext, crashLogFile))
                {
                    result = UnitTestResult.CreateFailure(GettextCatalog.GetString("Unhandled exception"), null);
                }
                else if (!localMonitor.Canceled)
                {
                    LoggingService.LogError(ex.ToString());
                    if (localMonitor.RunningTest != null)
                    {
                        RuntimeErrorCleanup(testContext, localMonitor.RunningTest, ex);
                    }
                    else
                    {
                        testContext.Monitor.ReportRuntimeError(null, ex);
                        throw;
                    }
                    result = UnitTestResult.CreateFailure(ex);
                }
                else
                {
                    result = UnitTestResult.CreateFailure(GettextCatalog.GetString("Canceled"), null);
                }
            } finally {
                File.Delete(crashLogFile);
                testContext.Monitor.CancelRequested -= new TestHandler(rd.Cancel);
                runner.Dispose();
                System.Runtime.Remoting.RemotingServices.Disconnect(localMonitor);
            }

            return(result);
        }
Exemplo n.º 45
0
		void ClearDetails ()
		{
			chart.Clear ();
			detailLabel.Markup = "";
			detailsStore.Clear ();
			if (detailsTest != null)
				detailsTest.TestChanged -= testChangedHandler;
			detailsTest = null;
			detailsDate = DateTime.MinValue;
			detailsReferenceDate = DateTime.MinValue;
			detailsPad.Sensitive = false;
		}
Exemplo n.º 46
0
 internal SourceCodeLocation GetSourceCodeLocation(UnitTest test)
 {
     return(GetSourceCodeLocation(test.FixtureTypeNamespace, test.FixtureTypeName, test.Name));
 }
Exemplo n.º 47
0
		internal SourceCodeLocation GetSourceCodeLocation (UnitTest test)
		{
			return GetSourceCodeLocation (test.FixtureTypeNamespace, test.FixtureTypeName, test.Name);
		}
Exemplo n.º 48
0
        internal UnitTestResult RunUnitTest(UnitTest test, string suiteName, string pathName, string testName, TestContext testContext)
        {
            var runnerExe = GetCustomConsoleRunnerCommand();

            if (runnerExe != null)
            {
                return(RunWithConsoleRunner(runnerExe, test, suiteName, pathName, testName, testContext));
            }

            ExternalTestRunner runner       = (ExternalTestRunner)Runtime.ProcessService.CreateExternalProcessObject(typeof(ExternalTestRunner), testContext.ExecutionContext, UserAssemblyPaths);
            LocalTestMonitor   localMonitor = new LocalTestMonitor(testContext, test, suiteName, testName != null);

            ITestFilter filter = null;

            if (test != null)
            {
                if (test is UnitTestGroup)
                {
                    filter = new TestNameFilter(CollectTests((UnitTestGroup)test));
                }
                else
                {
                    filter = new TestNameFilter(test.TestId);
                }
            }
            else
            {
                NUnitCategoryOptions categoryOptions = (NUnitCategoryOptions)test.GetOptions(typeof(NUnitCategoryOptions));
                if (categoryOptions.EnableFilter && categoryOptions.Categories.Count > 0)
                {
                    string[] cats = new string [categoryOptions.Categories.Count];
                    categoryOptions.Categories.CopyTo(cats, 0);
                    filter = new CategoryFilter(cats);
                    if (categoryOptions.Exclude)
                    {
                        filter = new NotFilter(filter);
                    }
                }
            }

            RunData rd = new RunData();

            rd.Runner       = runner;
            rd.Test         = this;
            rd.LocalMonitor = localMonitor;
            testContext.Monitor.CancelRequested += new TestHandler(rd.Cancel);

            UnitTestResult result;

            try {
                if (string.IsNullOrEmpty(AssemblyPath))
                {
                    string msg = GettextCatalog.GetString("Could not get a valid path to the assembly. There may be a conflict in the project configurations.");
                    throw new Exception(msg);
                }
                System.Runtime.Remoting.RemotingServices.Marshal(localMonitor, null, typeof(IRemoteEventListener));

                string testRunnerAssembly, testRunnerType;
                GetCustomTestRunner(out testRunnerAssembly, out testRunnerType);

                result = runner.Run(localMonitor, filter, AssemblyPath, "", new List <string> (SupportAssemblies), testRunnerType, testRunnerAssembly);
                if (testName != null)
                {
                    result = localMonitor.SingleTestResult;
                }
            } catch (Exception ex) {
                if (!localMonitor.Canceled)
                {
                    LoggingService.LogError(ex.ToString());
                    if (localMonitor.RunningTest != null)
                    {
                        RuntimeErrorCleanup(testContext, localMonitor.RunningTest, ex);
                    }
                    else
                    {
                        testContext.Monitor.ReportRuntimeError(null, ex);
                        throw ex;
                    }
                    result = UnitTestResult.CreateFailure(ex);
                }
                else
                {
                    result = UnitTestResult.CreateFailure(GettextCatalog.GetString("Canceled"), null);
                }
            } finally {
                testContext.Monitor.CancelRequested -= new TestHandler(rd.Cancel);
                runner.Dispose();
                System.Runtime.Remoting.RemotingServices.Disconnect(localMonitor);
            }

            return(result);
        }
Exemplo n.º 49
0
		UnitTestResult RunWithConsoleRunner (ProcessExecutionCommand cmd, UnitTest test, string suiteName, string pathName, string testName, TestContext testContext)
		{
			var outFile = Path.GetTempFileName ();
			LocalConsole cons = new LocalConsole ();

			try {
				MonoDevelop.NUnit.External.TcpTestListener tcpListener = null;
				LocalTestMonitor localMonitor = new LocalTestMonitor (testContext, test, suiteName, testName != null);

				if (!string.IsNullOrEmpty (cmd.Arguments))
					cmd.Arguments += " ";
				cmd.Arguments += "\"-xml=" + outFile + "\" " + AssemblyPath;

				bool automaticUpdates = cmd.Command != null && (cmd.Command.Contains ("GuiUnit") || (cmd.Command.Contains ("mdtool.exe") && cmd.Arguments.Contains ("run-md-tests")));
				if (!string.IsNullOrEmpty(pathName))
					cmd.Arguments += " -run=" + test.TestId;
				if (automaticUpdates) {
					tcpListener = new MonoDevelop.NUnit.External.TcpTestListener (localMonitor, suiteName);
					cmd.Arguments += " -port=" + tcpListener.Port;
				}

				// Note that we always dispose the tcp listener as we don't want it listening
				// forever if the test runner does not try to connect to it
				using (tcpListener) {
					using (var p = testContext.ExecutionContext.Execute (cmd, cons)) {
						testContext.Monitor.CancelRequested += p.Cancel;
						if (testContext.Monitor.IsCancelRequested)
							p.Cancel ();
						p.WaitForCompleted ();
						testContext.Monitor.CancelRequested -= p.Cancel;
					}
					
					if (new FileInfo (outFile).Length == 0)
						throw new Exception ("Command failed");
				}

				// mdtool.exe does not necessarily guarantee we get automatic updates. It just guarantees
				// that if guiunit is being used then it will give us updates. If you have a regular test
				// assembly compiled against nunit.framework.dll 
				if (automaticUpdates && tcpListener.HasReceivedConnection) {
					if (testName != null)
						return localMonitor.SingleTestResult;
					return test.GetLastResult ();
				}

				XDocument doc = XDocument.Load (outFile);

				if (doc.Root != null) {
					var root = doc.Root.Elements ("test-suite").FirstOrDefault ();
					if (root != null) {
						cons.SetDone ();
						var ot = cons.Out.ReadToEnd ();
						var et = cons.Error.ReadToEnd ();
						testContext.Monitor.WriteGlobalLog (ot);
						if (!string.IsNullOrEmpty (et)) {
							testContext.Monitor.WriteGlobalLog ("ERROR:\n");
							testContext.Monitor.WriteGlobalLog (et);
						}

						bool macunitStyle = doc.Root.Element ("environment") != null && doc.Root.Element ("environment").Attribute ("macunit-version") != null;
						var result = ReportXmlResult (localMonitor, root, "", macunitStyle);
						if (testName != null)
							result = localMonitor.SingleTestResult;
						return result;
					}
				}
				throw new Exception ("Test results could not be parsed.");
			} catch (Exception ex) {
				cons.SetDone ();
				var ot = cons.Out.ReadToEnd ();
				var et = cons.Error.ReadToEnd ();
				testContext.Monitor.WriteGlobalLog (ot);
				if (!string.IsNullOrEmpty (et)) {
					testContext.Monitor.WriteGlobalLog ("ERROR:\n");
					testContext.Monitor.WriteGlobalLog (et);
				}
				testContext.Monitor.ReportRuntimeError ("Test execution failed.\n" + ot + "\n" + et, ex);
				return UnitTestResult.CreateIgnored ("Test execution failed");
			} finally {
				File.Delete (outFile);
				cons.Dispose ();
			}
		}
Exemplo n.º 50
0
        UnitTestResult RunWithConsoleRunner(ProcessExecutionCommand cmd, UnitTest test, string suiteName, string pathName, string testName, TestContext testContext)
        {
            var          outFile = Path.GetTempFileName();
            LocalConsole cons    = new LocalConsole();

            try {
                MonoDevelop.NUnit.External.TcpTestListener tcpListener = null;
                LocalTestMonitor localMonitor = new LocalTestMonitor(testContext, test, suiteName, testName != null);

                if (!string.IsNullOrEmpty(cmd.Arguments))
                {
                    cmd.Arguments += " ";
                }
                cmd.Arguments += "\"-xml=" + outFile + "\" " + AssemblyPath;

                bool automaticUpdates = cmd.Command.Contains("GuiUnit") || (cmd.Command.Contains("mdtool.exe") && cmd.Arguments.Contains("run-md-tests"));
                if (!string.IsNullOrEmpty(pathName))
                {
                    cmd.Arguments += " -run=" + pathName;
                }
                if (automaticUpdates)
                {
                    tcpListener    = new MonoDevelop.NUnit.External.TcpTestListener(localMonitor, suiteName);
                    cmd.Arguments += " -port=" + tcpListener.Port;
                }

                // Note that we always dispose the tcp listener as we don't want it listening
                // forever if the test runner does not try to connect to it
                using (tcpListener) {
                    var p = testContext.ExecutionContext.Execute(cmd, cons);

                    testContext.Monitor.CancelRequested += p.Cancel;
                    if (testContext.Monitor.IsCancelRequested)
                    {
                        p.Cancel();
                    }
                    p.WaitForCompleted();

                    if (new FileInfo(outFile).Length == 0)
                    {
                        throw new Exception("Command failed");
                    }
                }

                // mdtool.exe does not necessarily guarantee we get automatic updates. It just guarantees
                // that if guiunit is being used then it will give us updates. If you have a regular test
                // assembly compiled against nunit.framework.dll
                if (automaticUpdates && tcpListener.HasReceivedConnection)
                {
                    if (testName != null)
                    {
                        return(localMonitor.SingleTestResult);
                    }
                    return(test.GetLastResult());
                }

                XDocument doc = XDocument.Load(outFile);

                if (doc.Root != null)
                {
                    var root = doc.Root.Elements("test-suite").FirstOrDefault();
                    if (root != null)
                    {
                        cons.SetDone();
                        var ot = cons.Out.ReadToEnd();
                        var et = cons.Error.ReadToEnd();
                        testContext.Monitor.WriteGlobalLog(ot);
                        if (!string.IsNullOrEmpty(et))
                        {
                            testContext.Monitor.WriteGlobalLog("ERROR:\n");
                            testContext.Monitor.WriteGlobalLog(et);
                        }

                        bool macunitStyle = doc.Root.Element("environment") != null && doc.Root.Element("environment").Attribute("macunit-version") != null;
                        var  result       = ReportXmlResult(localMonitor, root, "", macunitStyle);
                        if (testName != null)
                        {
                            result = localMonitor.SingleTestResult;
                        }
                        return(result);
                    }
                }
                throw new Exception("Test results could not be parsed.");
            } catch (Exception ex) {
                cons.SetDone();
                var ot = cons.Out.ReadToEnd();
                var et = cons.Error.ReadToEnd();
                testContext.Monitor.WriteGlobalLog(ot);
                if (!string.IsNullOrEmpty(et))
                {
                    testContext.Monitor.WriteGlobalLog("ERROR:\n");
                    testContext.Monitor.WriteGlobalLog(et);
                }
                testContext.Monitor.ReportRuntimeError("Test execution failed.\n" + ot + "\n" + et, ex);
                return(UnitTestResult.CreateIgnored("Test execution failed"));
            } finally {
                File.Delete(outFile);
            }
        }
 internal SourceCodeLocation GetSourceCodeLocation(UnitTest test)
 {
     if (test is NUnitTestCase) {
         NUnitTestCase t = (NUnitTestCase) test;
         return GetSourceCodeLocation (t.ClassName, t.Name);
     } else if (test is NUnitTestSuite) {
         NUnitTestSuite t = (NUnitTestSuite) test;
         return GetSourceCodeLocation (t.ClassName, null);
     } else
         return null;
 }
 public new void Clear()
 {
     base.Clear();
     test = null;
 }
 void RuntimeErrorCleanup(TestContext testContext, UnitTest t, Exception ex)
 {
     UnitTestResult result = UnitTestResult.CreateFailure (ex);
     t.RegisterResult (testContext, result);
     while (t != null && t != this) {
         testContext.Monitor.EndTest (t, result);
         t.Status = TestStatus.Ready;
         t = t.Parent;
     }
 }
        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);
                }
            }
        }
		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;
		}
Exemplo n.º 56
0
 public IAsyncOperation RunTest(UnitTest test, IExecutionHandler context)
 {
     return(RunTest(test, context, IdeApp.Preferences.BuildBeforeExecuting));
 }
		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));
		}
Exemplo n.º 58
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);
        }
Exemplo n.º 59
0
        protected void OnShowOptions()
        {
            UnitTest test = CurrentNode.DataItem as UnitTest;

            NUnitService.ShowOptionsDialog(test);
        }
Exemplo n.º 60
0
 public void InitializeTestRun(UnitTest test)
 {
     DispatchService.GuiDispatch(delegate {
         pad.InitializeTestRun(test);
     });
 }