Exemplo n.º 1
0
        /// <summary>
        /// Run the tests in the loaded TestPackage.
        /// </summary>
        /// <param name="listener">An ITestEventHandler to receive events</param>
        /// <param name="filter">A TestFilter used to select tests</param>
        /// <returns>
        /// A TestEngineResult giving the result of the test execution
        /// </returns>
        protected override TestEngineResult RunTests(ITestEventListener listener, TestFilter filter)
        {
            var result = new TestEngineResult();

            foreach (IFrameworkDriver driver in _drivers)
            {
                result.Add(driver.Run(listener, filter.Text));
            }

            if (IsProjectPackage(TestPackage))
            {
                result = result.MakePackageResult(TestPackage.Name, TestPackage.FullName);
            }

            var packages = TestPackage.SubPackages;

            if (packages.Count == 0)
            {
                packages.Add(TestPackage);
            }
            foreach (var package in packages)
            {
                _assemblyResolver.RemovePathFromFile(package.FullName);
            }

            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Run the tests in a loaded TestPackage
        /// </summary>
        /// <param name="listener">An ITestEventHandler to receive events</param>
        /// <param name="filter">A TestFilter used to select tests</param>
        /// <returns>
        /// A TestEngineResult giving the result of the test execution.
        /// </returns>
        protected override TestEngineResult RunTests(ITestEventListener listener, TestFilter filter)
        {
            var results = new List <TestEngineResult>();

            bool disposeRunners = TestPackage.GetSetting(PackageSettings.DisposeRunners, false);

            foreach (ITestEngineRunner runner in _runners)
            {
                results.Add(runner.Run(listener, filter));
                if (disposeRunners)
                {
                    runner.Dispose();
                }
            }
            if (disposeRunners)
            {
                _runners.Clear();
            }

            TestEngineResult result = ResultHelper.Merge(results);

            return(IsProjectPackage(TestPackage)
                ? result.MakePackageResult(TestPackage.Name, TestPackage.FullName)
                : result);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Load a TestPackage for exploration or execution
        /// </summary>
        /// <returns>A TestEngineResult.</returns>
        protected override TestEngineResult LoadPackage()
        {
            var result = new TestEngineResult();

            // DirectRunner may be called with a single-assembly package
            // or a set of assemblies as subpackages.
            var packages = TestPackage.SubPackages;
            if (packages.Count == 0)
                packages.Add(TestPackage);

            var driverService = Services.GetService<IDriverService>();

            foreach (var subPackage in packages)
            {
                var testFile = subPackage.FullName;
                IFrameworkDriver driver = driverService.GetDriver(TestDomain, testFile);
                driver.ID = TestPackage.ID;
                result.Add(driver.Load(testFile, subPackage.Settings));
                _drivers.Add(driver);
            }

            if (IsProjectPackage(TestPackage))
                result = result.MakePackageResult(TestPackage.Name, TestPackage.FullName);

            return result;
        }
        /// <summary>
        /// Explore a TestPackage and return information about
        /// the tests found.
        /// </summary>
        /// <param name="package">The TestPackage to be explored</param>
        /// <returns>A TestEngineResult.</returns>
        protected override TestEngineResult ExploreTests(TestFilter filter)
        {
            TestEngineResult result = new TestEngineResult();

            foreach (IFrameworkDriver driver in _drivers)
                result.Add(driver.Explore(filter));

            return IsProjectPackage(this.TestPackage)
                ? result.MakePackageResult(TestPackage.Name, TestPackage.FullName)
                : result;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Run the tests in the loaded TestPackage.
        /// </summary>
        /// <param name="listener">An ITestEventHandler to receive events</param>
        /// <param name="filter">A TestFilter used to select tests</param>
        /// <returns>
        /// A TestEngineResult giving the result of the test execution
        /// </returns>
        protected override TestEngineResult RunTests(ITestEventListener listener, TestFilter filter)
        {
            var result = new TestEngineResult();

            foreach (IFrameworkDriver driver in _drivers)
                result.Add(driver.Run(listener, filter.Text));

            if (IsProjectPackage(TestPackage))
                result = result.MakePackageResult(TestPackage.Name, TestPackage.FullName);

            return result;
        }
Exemplo n.º 6
0
        /// <summary>
        /// Explores a previously loaded TestPackage and returns information
        /// about the tests found.
        /// </summary>
        /// <param name="filter">The TestFilter to be used to select tests</param>
        /// <returns>
        /// A TestEngineResult.
        /// </returns>
        protected override TestEngineResult ExploreTests(TestFilter filter)
        {
            var result = new TestEngineResult();

            foreach (IFrameworkDriver driver in _drivers)
                result.Add(driver.Explore(filter.Text));

            if (IsProjectPackage(TestPackage))
                result = result.MakePackageResult(TestPackage.Name, TestPackage.FullName);

            return result;
        }
Exemplo n.º 7
0
        /// <summary>
        /// Run the tests in a loaded TestPackage
        /// </summary>
        /// <param name="filter">A TestFilter used to select tests</param>
        /// <returns>
        /// A TestEngineResult giving the result of the test execution. The
        /// top-level node of the result is &lt;direct-runner&gt; and wraps
        /// all the &lt;test-assembly&gt; elements returned by the drivers.
        /// </returns>
        public override TestEngineResult Run(ITestEventHandler listener, TestFilter filter)
        {
            TestEngineResult result = new TestEngineResult();

            foreach (IFrameworkDriver driver in drivers)
            {
                result.Add(driver.Run(listener, filter));
            }

            return(IsProjectPackage(this.package)
                ? result.MakePackageResult(package.Name, package.FullName)
                : result);
        }
        /// <summary>
        /// Explore a TestPackage and return information about
        /// the tests found.
        /// </summary>
        /// <param name="package">The TestPackage to be explored</param>
        /// <returns>A TestEngineResult.</returns>
        protected override TestEngineResult ExploreTests(TestFilter filter)
        {
            TestEngineResult result = new TestEngineResult();

            foreach (IFrameworkDriver driver in _drivers)
            {
                result.Add(driver.Explore(filter));
            }

            return(IsProjectPackage(this.TestPackage)
                ? result.MakePackageResult(TestPackage.Name, TestPackage.FullName)
                : result);
        }
        /// <summary>
        /// Run the tests in a loaded TestPackage
        /// </summary>
        /// <param name="filter">A TestFilter used to select tests</param>
        /// <returns>
        /// A TestEngineResult giving the result of the test execution. The
        /// top-level node of the result is &lt;direct-runner&gt; and wraps
        /// all the &lt;test-assembly&gt; elements returned by the drivers.
        /// </returns>
        protected override TestEngineResult RunTests(ITestEventListener listener, TestFilter filter)
        {
            TestEngineResult result = new TestEngineResult();

            foreach (IFrameworkDriver driver in _drivers)
            {
                result.Add(driver.Run(listener, filter));
            }

            return(IsProjectPackage(this.TestPackage)
                ? result.MakePackageResult(TestPackage.Name, TestPackage.FullName)
                : result);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Run the tests in a loaded TestPackage
        /// </summary>
        /// <param name="listener">An ITestEventHandler to receive events</param>
        /// <param name="filter">A TestFilter used to select tests</param>
        /// <returns>
        /// A TestEngineResult giving the result of the test execution.
        /// </returns>
        protected override TestEngineResult RunTests(ITestEventListener listener, TestFilter filter)
        {
            var results = new List <TestEngineResult>();

            bool disposeRunners = TestPackage.GetSetting(PackageSettings.DisposeRunners, false);

            int levelOfParallelism = GetLevelOfParallelism();

            if (levelOfParallelism <= 1 || _runners.Count <= 1)
            {
                foreach (ITestEngineRunner runner in _runners)
                {
                    results.Add(runner.Run(listener, filter));
                    if (disposeRunners)
                    {
                        runner.Dispose();
                    }
                }
            }
            else
            {
                var workerPool = new ParallelTaskWorkerPool(levelOfParallelism);
                var tasks      = new List <TestExecutionTask>();

                foreach (ITestEngineRunner runner in _runners)
                {
                    var task = new TestExecutionTask(runner, listener, filter, disposeRunners);
                    tasks.Add(task);
                    workerPool.Enqueue(task);
                }

                workerPool.Start();
                workerPool.WaitAll();

                foreach (var task in tasks)
                {
                    results.Add(task.Result());
                }
            }

            if (disposeRunners)
            {
                _runners.Clear();
            }

            TestEngineResult result = ResultHelper.Merge(results);

            return(IsProjectPackage(TestPackage)
                ? result.MakePackageResult(TestPackage.Name, TestPackage.FullName)
                : result);
        }
Exemplo n.º 11
0
        private TestEngineResult PrepareResult(TestEngineResult result)
        {
            if (result == null)
            {
                throw new ArgumentNullException("result");
            }

            if (!IsProjectPackage(TestPackage))
            {
                return(result);
            }

            return(result.MakePackageResult(TestPackage.Name, TestPackage.FullName));
        }
Exemplo n.º 12
0
        /// <summary>
        /// Load a TestPackage for exploration or execution
        /// </summary>
        /// <param name="package">The TestPackage to be loaded</param>
        /// <returns>A TestEngineResult.</returns>
        protected override TestEngineResult LoadPackage()
        {
            TestEngineResult result = new TestEngineResult();

            foreach (string testFile in TestPackage.TestFiles)
            {
                IFrameworkDriver driver = Services.DriverFactory.GetDriver(TestDomain, testFile, TestPackage.Settings);
                result.Add(driver.Load());
                _drivers.Add(driver);
            }

            return IsProjectPackage(TestPackage)
                ? result.MakePackageResult(TestPackage.Name, TestPackage.FullName)
                : result;
        }
        /// <summary>
        /// Explore a TestPackage and return information about
        /// the tests found.
        /// </summary>
        /// <param name="package">The TestPackage to be explored</param>
        /// <returns>A TestEngineResult.</returns>
        protected override TestEngineResult ExploreTests(TestFilter filter)
        {
            List <TestEngineResult> results = new List <TestEngineResult>();

            foreach (ITestEngineRunner runner in _runners)
            {
                results.Add(runner.Explore(filter));
            }

            TestEngineResult result = ResultHelper.Merge(results);

            return(IsProjectPackage(this.TestPackage)
                ? result.MakePackageResult(TestPackage.Name, TestPackage.FullName)
                : result);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Load a TestPackage for exploration or execution
        /// </summary>
        /// <param name="package">The TestPackage to be loaded</param>
        /// <returns>A TestEngineResult.</returns>
        protected override TestEngineResult LoadPackage()
        {
            TestEngineResult result = new TestEngineResult();

            foreach (string testFile in TestPackage.TestFiles)
            {
                IFrameworkDriver driver = Services.DriverFactory.GetDriver(TestDomain, testFile, TestPackage.Settings);
                result.Add(driver.Load());
                _drivers.Add(driver);
            }

            return(IsProjectPackage(TestPackage)
                ? result.MakePackageResult(TestPackage.Name, TestPackage.FullName)
                : result);
        }
Exemplo n.º 15
0
        /// <summary>
        /// Load a TestPackage for exploration or execution
        /// </summary>
        /// <param name="package">The TestPackage to be loaded</param>
        /// <returns>A TestEngineResult.</returns>
        public override TestEngineResult Load(TestPackage package)
        {
            this.package = package;
            TestEngineResult result = new TestEngineResult();

            foreach (string testFile in package.TestFiles)
            {
                IFrameworkDriver driver = Services.DriverFactory.GetDriver(TestDomain, testFile, package.Settings);
                result.Add(driver.Load());
                drivers.Add(driver);
            }

            return(IsProjectPackage(this.package)
                ? result.MakePackageResult(package.Name, package.FullName)
                : result);
        }
Exemplo n.º 16
0
        /// <summary>
        /// Explore a TestPackage and return information about
        /// the tests found.
        /// </summary>
        /// <param name="package">The TestPackage to be explored</param>
        /// <returns>A TestEngineResult.</returns>
        public override TestEngineResult Explore(TestFilter filter)
        {
            List <TestEngineResult> results = new List <TestEngineResult>();

            // TODO: Eliminate need for implicit cast to AbstractTestRunner
            foreach (AbstractTestRunner runner in runners)
            {
                results.Add(runner.Explore(filter));
            }

            TestEngineResult result = ResultHelper.Merge(results);

            return(IsProjectPackage(this.package)
                ? result.MakePackageResult(package.Name, package.FullName)
                : result);
        }
Exemplo n.º 17
0
        /// <summary>
        /// Run the tests in the loaded TestPackage.
        /// </summary>
        /// <param name="listener">An ITestEventHandler to receive events</param>
        /// <param name="filter">A TestFilter used to select tests</param>
        /// <returns>
        /// A TestEngineResult giving the result of the test execution
        /// </returns>
        protected override TestEngineResult RunTests(ITestEventListener listener, TestFilter filter)
        {
            var result = new TestEngineResult();

            foreach (IFrameworkDriver driver in _drivers)
            {
                result.Add(driver.Run(listener, filter));
            }

#if NUNIT_ENGINE
            if (IsProjectPackage(TestPackage))
            {
                result = result.MakePackageResult(TestPackage.Name, TestPackage.FullName);
            }
#endif

            return(result);
        }
Exemplo n.º 18
0
        /// <summary>
        /// Explores a previously loaded TestPackage and returns information
        /// about the tests found.
        /// </summary>
        /// <param name="filter">The TestFilter to be used to select tests</param>
        /// <returns>
        /// A TestEngineResult.
        /// </returns>
        protected override TestEngineResult ExploreTests(TestFilter filter)
        {
            var result = new TestEngineResult();

            foreach (IFrameworkDriver driver in _drivers)
            {
                result.Add(driver.Explore(filter.Text));
            }

#if NUNIT_ENGINE
            if (IsProjectPackage(TestPackage))
            {
                result = result.MakePackageResult(TestPackage.Name, TestPackage.FullName);
            }
#endif

            return(result);
        }
Exemplo n.º 19
0
        /// <summary>
        /// Load a TestPackage for exploration or execution
        /// </summary>
        /// <returns>A TestEngineResult.</returns>
        protected override TestEngineResult LoadPackage()
        {
            var result = new TestEngineResult();

            // DirectRunner may be called with a single-assembly package
            // or a set of assemblies as subpackages.
            var packages = TestPackage.SubPackages;

            if (packages.Count == 0)
            {
                packages.Add(TestPackage);
            }

            var driverService = Services.GetService <IDriverService>();

            foreach (var subPackage in packages)
            {
                var testFile = subPackage.FullName;

                if (_assemblyResolver != null && !TestDomain.IsDefaultAppDomain() &&
                    subPackage.GetSetting(PackageSettings.ImageRequiresDefaultAppDomainAssemblyResolver, false))
                {
                    // It's OK to do this in the loop because the Add method
                    // checks to see if the path is already present.
                    _assemblyResolver.AddPathFromFile(testFile);
                }

                var targetFramework = subPackage.GetSetting(PackageSettings.ImageTargetFrameworkName, (string)null);

                IFrameworkDriver driver = driverService.GetDriver(TestDomain, testFile, targetFramework);
                driver.ID = TestPackage.ID;
                result.Add(driver.Load(testFile, subPackage.Settings));
                _drivers.Add(driver);
            }

            if (IsProjectPackage(TestPackage))
            {
                result = result.MakePackageResult(TestPackage.Name, TestPackage.FullName);
            }

            return(result);
        }
Exemplo n.º 20
0
        /// <summary>
        /// Run the tests in the loaded TestPackage.
        /// </summary>
        /// <param name="listener">An ITestEventHandler to receive events</param>
        /// <param name="filter">A TestFilter used to select tests</param>
        /// <returns>
        /// A TestEngineResult giving the result of the test execution
        /// </returns>
        protected override TestEngineResult RunTests(ITestEventListener listener, TestFilter filter)
        {
            var result = new TestEngineResult();

            foreach (IFrameworkDriver driver in _drivers)
            {
                result.Add(driver.Run(listener, filter.Text));
            }

            if (IsProjectPackage(TestPackage))
                result = result.MakePackageResult(TestPackage.Name, TestPackage.FullName);

            if (_assemblyResolver != null)
            {
                var packages = TestPackage.SubPackages;

                if (packages.Count == 0)
                    packages.Add(TestPackage);

                foreach (var package in packages)
                    _assemblyResolver.RemovePathFromFile(package.FullName);
            }

            return result;
        }
Exemplo n.º 21
0
        /// <summary>
        /// Load a TestPackage for exploration or execution
        /// </summary>
        /// <returns>A TestEngineResult.</returns>
        protected override TestEngineResult LoadPackage()
        {
            var result = new TestEngineResult();

            // DirectRunner may be called with a single-assembly package
            // or a set of assemblies as subpackages.
            var packages = TestPackage.SubPackages;
            if (packages.Count == 0)
                packages.Add(TestPackage);

            var driverService = Services.GetService<IDriverService>();

            foreach (var subPackage in packages)
            {
                var testFile = subPackage.FullName;

                if (_assemblyResolver != null && !TestDomain.IsDefaultAppDomain()
                    && subPackage.GetSetting(InternalEnginePackageSettings.ImageRequiresDefaultAppDomainAssemblyResolver, false))
                {
                    // It's OK to do this in the loop because the Add method 
                    // checks to see if the path is already present.
                    _assemblyResolver.AddPathFromFile(testFile);
                }

                var targetFramework = subPackage.GetSetting(InternalEnginePackageSettings.ImageTargetFrameworkName, (string)null);

                IFrameworkDriver driver = driverService.GetDriver(TestDomain, testFile, targetFramework);
                driver.ID = TestPackage.ID;
                result.Add(driver.Load(testFile, subPackage.Settings));
                _drivers.Add(driver);
            }

            if (IsProjectPackage(TestPackage))
                result = result.MakePackageResult(TestPackage.Name, TestPackage.FullName);

            return result;
        }