Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeting Yang <ketyang@microsoft.com>2019-09-17 16:38:05 +0300
committerGitHub <noreply@github.com>2019-09-17 16:38:05 +0300
commit1abc0b5c2336147e0cbeca63a068fd006e71b00b (patch)
tree237b49967bd43c64fe1d9bbe91d45e85ae425676 /main/src/addins/MonoDevelop.UnitTesting
parent8f5ff39d3625dfb56c420c6f9f46dab1766e4aab (diff)
parent358ee0bcb03493a33f4d5bbd686589085a0f253c (diff)
Merge pull request #8424 from mono/vsts-802586-debug-all-tests
[Debugger] Add Debug All Test command
Diffstat (limited to 'main/src/addins/MonoDevelop.UnitTesting')
-rw-r--r--main/src/addins/MonoDevelop.UnitTesting/Commands/UnitTestCommands.cs44
-rw-r--r--main/src/addins/MonoDevelop.UnitTesting/Gui/TestPad.cs63
-rw-r--r--main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.addin.xml4
3 files changed, 97 insertions, 14 deletions
diff --git a/main/src/addins/MonoDevelop.UnitTesting/Commands/UnitTestCommands.cs b/main/src/addins/MonoDevelop.UnitTesting/Commands/UnitTestCommands.cs
index 6d0a84150d..7c1b64b284 100644
--- a/main/src/addins/MonoDevelop.UnitTesting/Commands/UnitTestCommands.cs
+++ b/main/src/addins/MonoDevelop.UnitTesting/Commands/UnitTestCommands.cs
@@ -29,6 +29,7 @@
using MonoDevelop.Components.Commands;
using MonoDevelop.Projects;
using MonoDevelop.Ide;
+using MonoDevelop.Core;
namespace MonoDevelop.UnitTesting.Commands
{
@@ -43,6 +44,7 @@ namespace MonoDevelop.UnitTesting.Commands
ShowTestDetails,
GoToFailure,
RerunTest,
+ DebugAllTests,
}
public enum TestChartCommands
@@ -72,7 +74,7 @@ namespace MonoDevelop.UnitTesting.Commands
{
protected override void Run ()
{
- WorkspaceObject ob = IdeApp.ProjectOperations.CurrentSelectedObject;
+ SolutionFolder ob = IdeApp.ProjectOperations.CurrentSelectedSolution?.RootFolder;
if (ob != null) {
UnitTest test = UnitTestService.FindRootTest (ob);
if (test != null)
@@ -82,7 +84,45 @@ namespace MonoDevelop.UnitTesting.Commands
protected override void Update (CommandInfo info)
{
- WorkspaceObject ob = IdeApp.ProjectOperations.CurrentSelectedObject;
+ SolutionFolder ob = IdeApp.ProjectOperations.CurrentSelectedSolution?.RootFolder;
+ if (ob != null) {
+ UnitTest test = UnitTestService.FindRootTest (ob);
+ info.Enabled = (test != null);
+ } else
+ info.Enabled = false;
+ }
+ }
+
+ class DebugAllTestsHandler : CommandHandler
+ {
+ protected async override void Run ()
+ {
+ SolutionFolder ob = IdeApp.ProjectOperations.CurrentSelectedSolution?.RootFolder;
+ if (ob != null) {
+ var testGroup = UnitTestService.FindRootTest (ob) as UnitTestGroup;
+ var tests = testGroup.Tests;
+ if (tests == null)
+ return;
+
+ var debugModeSet = Runtime.ProcessService.GetDebugExecutionMode ();
+ if (debugModeSet == null)
+ return;
+
+ foreach (UnitTest test in tests) {
+ foreach (var mode in debugModeSet.ExecutionModes) {
+ if (test.CanRun (mode.ExecutionHandler)) {
+ ExecutionContext context = new ExecutionContext (mode.ExecutionHandler, IdeApp.Workbench.ProgressMonitors.ConsoleFactory, null);
+ await UnitTestService.RunTests (new UnitTest [] { test }, context, true).Task;
+ continue;
+ }
+ }
+ }
+ }
+ }
+
+ protected override void Update (CommandInfo info)
+ {
+ SolutionFolder ob = IdeApp.ProjectOperations.CurrentSelectedSolution?.RootFolder;
if (ob != null) {
UnitTest test = UnitTestService.FindRootTest (ob);
info.Enabled = (test != null);
diff --git a/main/src/addins/MonoDevelop.UnitTesting/Gui/TestPad.cs b/main/src/addins/MonoDevelop.UnitTesting/Gui/TestPad.cs
index 235d0213f1..5b26fa011a 100644
--- a/main/src/addins/MonoDevelop.UnitTesting/Gui/TestPad.cs
+++ b/main/src/addins/MonoDevelop.UnitTesting/Gui/TestPad.cs
@@ -82,7 +82,7 @@ namespace MonoDevelop.UnitTesting
ArrayList testNavigationHistory = new ArrayList ();
- Button buttonRunAll, buttonStop;
+ Button buttonRunAll, buttonStop,buttonDebugAll;
public override void Initialize (NodeBuilder[] builders, TreePadOption[] options, string menuPath)
{
@@ -94,10 +94,7 @@ namespace MonoDevelop.UnitTesting
VBox vbox = new VBox ();
DockItemToolbar topToolbar = Window.GetToolbar (DockPositionType.Top);
- var hbox = new HBox { Spacing = 6 };
- hbox.PackStart (new ImageView (ImageService.GetIcon ("md-execute-all", IconSize.Menu)), false, false, 0);
- hbox.PackStart (new Label (GettextCatalog.GetString ("Run All")), false, false, 0);
- buttonRunAll = new Button (hbox);
+ buttonRunAll = new Button (new ImageView (ImageService.GetIcon ("md-execute-all", IconSize.Menu)));
buttonRunAll.Accessible.Name = "TestPad.RunAll";
buttonRunAll.Accessible.Description = GettextCatalog.GetString ("Start a test run and run all the tests");
buttonRunAll.Clicked += new EventHandler (OnRunAllClicked);
@@ -105,6 +102,14 @@ namespace MonoDevelop.UnitTesting
buttonRunAll.TooltipText = GettextCatalog.GetString ("Run all tests");
topToolbar.Add (buttonRunAll);
+ buttonDebugAll = new Button (new ImageView (ImageService.GetIcon ("md-debug-all", IconSize.Menu)));
+ buttonDebugAll.Accessible.Name = "TestPad.DebugAll";
+ buttonDebugAll.Accessible.Description = GettextCatalog.GetString ("Debug all the tests");
+ buttonDebugAll.Clicked += new EventHandler (OnDebugAllClicked);
+ buttonDebugAll.Sensitive = true;
+ buttonDebugAll.TooltipText = GettextCatalog.GetString ("Debug all tests");
+ topToolbar.Add (buttonDebugAll);
+
buttonStop = new Button (new ImageView (Ide.Gui.Stock.Stop, IconSize.Menu));
buttonStop.Clicked += new EventHandler (OnStopClicked);
buttonStop.Sensitive = false;
@@ -485,7 +490,7 @@ namespace MonoDevelop.UnitTesting
}
void StopRunningTests ()
- {
+ {
if (runningTestOperation != null)
runningTestOperation.Cancel ();
}
@@ -537,6 +542,7 @@ namespace MonoDevelop.UnitTesting
UnitTestService.ResetResult (test.RootTest);
this.buttonRunAll.Sensitive = false;
+ this.buttonDebugAll.Sensitive = false;
this.buttonStop.Sensitive = true;
ExecutionContext context = new ExecutionContext (mode, IdeApp.Workbench.ProgressMonitors.ConsoleFactory, null);
@@ -553,7 +559,39 @@ namespace MonoDevelop.UnitTesting
{
RunTest (TreeView.GetRootNode (), null);
}
-
+
+ async void OnDebugAllClicked (object sender, EventArgs args)
+ {
+ var nav = TreeView.GetRootNode ();
+ if (nav == null)
+ return;
+
+ var testGroup = nav.DataItem as UnitTestGroup;
+ var tests = testGroup.Tests;
+ if (tests == null)
+ return;
+
+ var debugModeSet = Runtime.ProcessService.GetDebugExecutionMode ();
+ if (debugModeSet == null)
+ return;
+
+ this.buttonRunAll.Sensitive = false;
+ this.buttonDebugAll.Sensitive = false;
+ this.buttonStop.Sensitive = true;
+
+ foreach (UnitTest test in tests) {
+ foreach (var mode in debugModeSet.ExecutionModes) {
+ if (test.CanRun (mode.ExecutionHandler)) {
+ ExecutionContext context = new ExecutionContext (mode.ExecutionHandler, IdeApp.Workbench.ProgressMonitors.ConsoleFactory, null);
+ await UnitTestService.RunTests (new UnitTest [] { test }, context, true).Task;
+ continue;
+ }
+ }
+ }
+
+ OnTestSessionCompleted ();
+ }
+
void RunSelectedTest (IExecutionHandler mode)
{
RunTests (TreeView.GetSelectedNodes (), mode);
@@ -565,6 +603,7 @@ namespace MonoDevelop.UnitTesting
runningTestOperation = null;
this.buttonRunAll.Sensitive = true;
this.buttonStop.Sensitive = false;
+ this.buttonDebugAll.Sensitive = true;
}
@@ -964,19 +1003,19 @@ namespace MonoDevelop.UnitTesting
protected override bool OnExposeEvent (Gdk.EventExpose args)
{
- using (Gdk.GC gc = new Gdk.GC (GdkWindow)) {
- gc.ClipRectangle = Allocation;
+ using (Gdk.GC gc = new Gdk.GC (GdkWindow)) {
+ gc.ClipRectangle = Allocation;
GdkWindow.DrawLayout (gc, padding, padding, layout);
}
return true;
}
- protected override void OnDestroyed ()
+ protected override void OnDestroyed ()
{
if (layout != null) {
layout.Dispose ();
layout = null;
- }
- base.OnDestroyed ();
+ }
+ base.OnDestroyed ();
}
}
}
diff --git a/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.addin.xml b/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.addin.xml
index 4fd591a678..c09038a505 100644
--- a/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.addin.xml
+++ b/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.addin.xml
@@ -62,6 +62,10 @@
<Command id = "MonoDevelop.UnitTesting.Commands.TestCommands.DebugTest"
_label = "Debug Test"
type="array" />
+ <Command id = "MonoDevelop.UnitTesting.Commands.TestCommands.DebugAllTests"
+ _label = "Debug All Tests"
+ _description="Debug all tests of the current selected project."
+ defaultHandler="MonoDevelop.UnitTesting.Commands.DebugAllTestsHandler"/>
<Command id = "MonoDevelop.UnitTesting.Commands.TestCommands.RunTest" _label = "Run Test" />
<Command id = "MonoDevelop.UnitTesting.Commands.TestCommands.ShowTestCode" _label = "Show test source code" />
<Command id = "MonoDevelop.UnitTesting.Commands.TestCommands.GoToFailure" _label = "Go to failure" />