Exemplo n.º 1
0
        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;
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        string[] GetTestNames()
        {
            var solution = DataObject as Solution;
            var rootTest = UnitTestService.FindRootTest(solution.RootFolder) as UnitTestGroup;
            var tests    = rootTest?.Tests;

            return(tests != null?tests.Select(t => t.Name).Concat(new string[]
            {
                EmptyChoice
            })?.ToArray() : new string[] { EmptyChoice });
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
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);
                }
            }
        }
Exemplo n.º 5
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;
        }
Exemplo n.º 6
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);
                }
            }
        }
Exemplo n.º 7
0
        protected override void Update(CommandInfo info)
        {
            SolutionFolder ob = IdeApp.ProjectOperations.CurrentSelectedSolution?.RootFolder;

            if (ob != null)
            {
                UnitTest test = UnitTestService.FindRootTest(ob);
                info.Enabled = (test != null);
            }
            else
            {
                info.Enabled = false;
            }
        }
Exemplo n.º 8
0
        protected override void Update(CommandInfo info)
        {
            WorkspaceObject ob = IdeApp.ProjectOperations.CurrentSelectedObject;

            if (ob != null)
            {
                UnitTest test = UnitTestService.FindRootTest(ob);
                info.Enabled = (test != null);
            }
            else
            {
                info.Enabled = false;
            }
        }
Exemplo n.º 9
0
        void RefreshTestProjectList()
        {
            List <Project> projects = new List <Project>();

            foreach (Project project in IdeApp.Workspace.GetAllProjects())
            {
                if (UnitTestService.FindRootTest(project) == null)
                {
                    continue;
                }
                projects.Add(project);
            }
            TestProjects = projects;
            TestProjectsChanged?.Invoke();
        }