diff options
Diffstat (limited to 'main/src/addins/MonoDevelop.UnitTesting')
-rw-r--r-- | main/src/addins/MonoDevelop.UnitTesting/Services/UnitTestService.cs | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/main/src/addins/MonoDevelop.UnitTesting/Services/UnitTestService.cs b/main/src/addins/MonoDevelop.UnitTesting/Services/UnitTestService.cs index 865e531c30..8ebf9a13c3 100644 --- a/main/src/addins/MonoDevelop.UnitTesting/Services/UnitTestService.cs +++ b/main/src/addins/MonoDevelop.UnitTesting/Services/UnitTestService.cs @@ -105,7 +105,7 @@ namespace MonoDevelop.UnitTesting public static AsyncOperation RunTest (UnitTest test, MonoDevelop.Projects.ExecutionContext context) { - var result = RunTest (test, context, IdeApp.Preferences.BuildBeforeRunningTests); + var result = RunTest (test, context, true); result.Task.ContinueWith (t => OnTestSessionCompleted (), TaskScheduler.FromCurrentSynchronizationContext ()); return result; } @@ -126,32 +126,26 @@ namespace MonoDevelop.UnitTesting if (buildOwnerObject) { var build_targets = new HashSet<IBuildTarget> (); foreach (var t in tests) { - IBuildTarget bt = t.OwnerObject as IBuildTarget; - if (bt != null) + if (t.OwnerObject is IBuildTarget bt) build_targets.Add (bt); } - if (build_targets.Count > 0) { - if (!IdeApp.ProjectOperations.CurrentRunOperation.IsCompleted) { - MonoDevelop.Ide.Commands.StopHandler.StopBuildOperations (); - await IdeApp.ProjectOperations.CurrentRunOperation.Task; - } - foreach (var bt in build_targets) { - var res = await IdeApp.ProjectOperations.Build (bt, cs.Token).Task; - if (res.HasErrors) - return; - } + var res = await IdeApp.ProjectOperations.CheckAndBuildForExecute ( + build_targets, IdeApp.Workspace.ActiveConfiguration, IdeApp.Preferences.BuildBeforeRunningTests, + false, null, cs.Token); + + if (!res) + return; - var test_names = new HashSet<string> (tests.Select ((v) => v.FullName)); + var test_names = new HashSet<string> (tests.Select ((v) => v.FullName)); - await RefreshTests (cs.Token); + await RefreshTests (cs.Token); - tests = test_names.Select ((fullName) => SearchTest (fullName)).Where ((t) => t != null).ToList (); + tests = test_names.Select ((fullName) => SearchTest (fullName)).Where ((t) => t != null).ToList (); - if (tests.Any ()) - await RunTests (tests, context, false, checkCurrentRunOperation, cs); - return; - } + if (tests.Any ()) + await RunTests (tests, context, false, checkCurrentRunOperation, cs); + return; } if (checkCurrentRunOperation && !IdeApp.ProjectOperations.ConfirmExecutionOperation ()) @@ -176,7 +170,7 @@ namespace MonoDevelop.UnitTesting public static AsyncOperation RunTests (IEnumerable<UnitTest> tests, MonoDevelop.Projects.ExecutionContext context) { - var result = RunTests (tests, context, IdeApp.Preferences.BuildBeforeRunningTests); + var result = RunTests (tests, context); result.Task.ContinueWith (t => OnTestSessionCompleted (), TaskScheduler.FromCurrentSynchronizationContext ()); return result; } |