Exemplo n.º 1
0
        public void ReloadTests()
        {
            _events.FireTestsReloading();

            // NOTE: The `ITestRunner.Reload` method supported by the engine
            // has some problems, so we simulate Unload+Load. See issue #328.

            // Replace Runner in case settings changed
            UnloadTestsIgnoringErrors();
            Runner.Dispose();
            Runner = TestEngine.GetRunner(TestPackage);

            // Discover tests
            Tests = new TestNode(Runner.Explore(NUnit.Engine.TestFilter.Empty));
            AvailableCategories = GetAvailableCategories();

            Results.Clear();

            _events.FireTestReloaded(Tests);
        }
Exemplo n.º 2
0
        // TODO: The NUnit engine is not returning project elements for each project
        // so we create them in this method. Remove when the engine is fixed.
        private TestNode ExploreTestPackage(TestPackage package)
        {
            var tests       = new TestNode(Runner.Explore(TestFilter.Empty));
            int nextId      = 10;
            int nextTest    = 0;
            int nextPackage = 0;

            while (nextPackage < package.SubPackages.Count && nextTest < tests.Children.Count)
            {
                var subPackage = package.SubPackages[nextPackage++];
                var childTest  = tests.Children[nextTest];

                if (subPackage.Name != childTest.Name)
                {
                    // SubPackage did not match the next child test node, so it must be a project.
                    var project   = new TestNode($"<test-suite type='Project' id='{nextId++}' name='{subPackage.Name}' fullname='{subPackage.FullName}' runstate='Runnable'/>");
                    int testCount = 0;

                    // Now move any children of this project under it
                    foreach (var subSubPackage in subPackage.SubPackages)
                    {
                        childTest = tests.Children[nextTest];

                        if (subSubPackage.Name == childTest.Name)
                        {
                            project.Children.Add(childTest);
                            tests.Children.RemoveAt(nextTest);
                            testCount += childTest.TestCount;
                        }
                    }

                    project.Xml.AddAttribute("testcasecount", testCount.ToString());
                    tests.Children.Insert(nextTest, project);
                }

                nextTest++;
            }

            return(tests);
        }
Exemplo n.º 3
0
        public void ReloadTests()
        {
            _events.FireTestsReloading();

            Runner.Unload();
            Results.Clear();
            Tests = null;

            TestPackage = MakeTestPackage(TestFiles);

            Runner = TestEngine.GetRunner(TestPackage);

            Tests = new TestNode(Runner.Explore(TestFilter.Empty));
            AvailableCategories = GetAvailableCategories();

            if (Services.UserSettings.Gui.ClearResultsOnReload)
            {
                Results.Clear();
            }

            _events.FireTestReloaded(Tests);
        }
Exemplo n.º 4
0
 public void FireTestReloaded(TestNode testNode)
 {
     TestReloaded?.Invoke(new TestNodeEventArgs(testNode));
 }
Exemplo n.º 5
0
 public ProjectInfo(TestNode projectNode)
 {
     ProjectNode     = projectNode;
     WasStarted      = false;
     AssembliesToRun = 0;
 }
Exemplo n.º 6
0
        //public static TestFilter FromXml(this XmlNode node)
        //{
        //    return new TestFilter(node.OuterXml);
        //}

        #endregion

        #region Methods to Create TestFilters

        public static TestFilter MakeIdFilter(TestNode test)
        {
            return(new TestFilter($"<filter><id>{test.Id}</id></filter>"));
        }
        //public void FireTestsReloading()
        //{
        //    TestsReloading?.Invoke(new TestEventArgs());
        //}

        //public void FireTestsUnloading()
        //{
        //    TestsUnloading?.Invoke(new TestEventArgs());
        //}

        public void FireTestLoaded(TestNode testNode)
        {
            TestLoaded?.Invoke(new TestNodeEventArgs(TestAction.TestLoaded, testNode));
        }