void RunTest(ITreeNavigator nav, IExecutionHandler mode) { if (nav == null) { return; } UnitTest test = nav.DataItem as UnitTest; if (test == null) { return; } TestSession.ResetResult(test.RootTest); this.buttonRun.Sensitive = false; this.buttonRunAll.Sensitive = false; this.buttonStop.Sensitive = true; IdeApp.Workbench.GetPad <TestPad> ().BringToFront(); runningTestOperation = testService.RunTest(test, mode); runningTestOperation.Completed += (OperationHandler)DispatchService.GuiDispatch(new OperationHandler(TestSessionCompleted)); }
internal IAsyncOperation RunTest (UnitTest test, IExecutionHandler context, bool buildOwnerObject, bool checkCurrentRunOperation) { 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 (checkCurrentRunOperation && !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; }); }; OnTestSessionStarting (new TestSessionEventArgs { Session = session, Test = test }); session.Start (); if (checkCurrentRunOperation) IdeApp.ProjectOperations.CurrentRunOperation = session; return session; }
internal IAsyncOperation RunTest(UnitTest test, IExecutionHandler context, bool buildOwnerObject, bool checkCurrentRunOperation) { 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 (checkCurrentRunOperation && !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; }); }; OnTestSessionStarting(new TestSessionEventArgs { Session = session, Test = test }); session.Start(); if (checkCurrentRunOperation) { IdeApp.ProjectOperations.CurrentRunOperation = session; } return(session); }
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; } } 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"); } resultsPad.BringToFront (); TestSession session = new TestSession (test, context, (TestResultsPad) resultsPad.Content); session.Start (); return session; }
public IAsyncOperation RunTest(UnitTest test) { if (resultsPad == null) { resultsPad = new TestResultsPad (); Runtime.Gui.Workbench.ShowPad (resultsPad); } Runtime.Gui.Workbench.BringToFront (resultsPad); TestSession session = new TestSession (test, resultsPad); session.Start (); return session; }
internal async Task RunTest (UnitTest test, IExecutionHandler 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.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, cs); OnTestSessionStarting (new TestSessionEventArgs { Session = session, Test = test }); if (checkCurrentRunOperation) IdeApp.ProjectOperations.CurrentRunOperation = session; try { await session.Start (); } finally { resultsPad.Sticky = false; } }
internal async Task RunTest(UnitTest test, IExecutionHandler 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.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, cs); OnTestSessionStarting(new TestSessionEventArgs { Session = session, Test = test }); if (checkCurrentRunOperation) { IdeApp.ProjectOperations.CurrentRunOperation = session; } try { await session.Start(); } finally { resultsPad.Sticky = false; } }