예제 #1
0
        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);
        }
예제 #2
0
        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);
                }
            }
        }
예제 #3
0
        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;
        }
예제 #4
0
        protected override void Run()
        {
            WorkspaceObject ob = IdeApp.ProjectOperations.CurrentSelectedObject;

            if (ob != null)
            {
                UnitTest test = UnitTestService.FindRootTest(ob);
                if (test != null)
                {
                    UnitTestService.RunTest(test, null);
                }
            }
        }