async Task RunTests(IEnumerable <ProjectFileEventArgs> l) { if (l.Count() == 1 && l.First().First().ProjectFile.FilePath.FileName.ToLower().StartsWith("resource.designer")) { return; } var commonProject = l.Select(r => r.CommonProject).Distinct().First(); var rootTest = UnitTestService.FindRootTest(commonProject.ParentSolution.RootFolder); HashSet <UnitTest> tests = new HashSet <UnitTest>(); var rootGroup = rootTest as UnitTestGroup; foreach (var e in l) { foreach (var file in e) { foreach (var testGroup in rootGroup.Tests) { if (AddInPreferences.ProjectTestMap.Any(p => p.Project == file.Project.Name && p.Test == testGroup.Name)) { tests.Add(testGroup); } } } } var coll = new CustomTestGroup( "Specified tests", rootTest.OwnerObject ); var context = new MonoDevelop.Projects.ExecutionContext( Runtime.ProcessService.DefaultExecutionHandler, IdeApp.Workbench.ProgressMonitors.ConsoleFactory, IdeApp.Workspace.ActiveExecutionTarget); foreach (var test in tests) { var tmp = new CustomTestGroup("this isnt a real test", test.OwnerObject); // We're only calling this so that the owner object gets built properly. // This will fail to run the tests because it tries to find the test // by name again after building the project, in case it was removed. // Since this is a temporary test group, it won't find it and will just return. await UnitTestService.RunTest(tmp, context).Task; coll.Tests.Add(test); } // To get around this, run the tests again but don't build the owner object: UnitTestService.RunTest(coll, context, false); }
protected override void Run() { SolutionFolder ob = IdeApp.ProjectOperations.CurrentSelectedSolution?.RootFolder; if (ob != null) { UnitTest test = UnitTestService.FindRootTest(ob); if (test != null) { UnitTestService.RunTest(test, null); } } }
protected virtual async Task RunTests(Project testProject) { IExecutionHandler mode = null; ExecutionContext context = new ExecutionContext(mode, IdeApp.Workbench.ProgressMonitors.ConsoleFactory, null); var firstRootTest = UnitTestService.FindRootTest(testProject); if (coverageCollectionCompletion != null || firstRootTest == null || !firstRootTest.CanRun(mode)) { return; } coverageCollectionCompletion = new TaskCompletionSource <bool>(); await UnitTestService.RunTest(firstRootTest, context, true).Task; }
protected override void Run() { WorkspaceObject ob = IdeApp.ProjectOperations.CurrentSelectedObject; if (ob != null) { UnitTest test = UnitTestService.FindRootTest(ob); if (test != null) { UnitTestService.RunTest(test, null); } } }