示例#1
0
        public void Load_Passes_Along_NUnitEngineException()
        {
            _driver.Load(Arg.Any <string>(), Arg.Any <Dictionary <string, object> >()).Throws(new NUnitEngineException("Message"));
            var ex = Assert.Throws <NUnitEngineException>(() => _directTestRunner.Load());

            Assert.That(ex.Message, Is.EqualTo("Message"));
        }
示例#2
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;
        }
示例#3
0
        /// <summary>
        /// Load a TestPackage for exploration or execution
        /// </summary>
        /// <returns>A TestEngineResult.</returns>
        protected override TestEngineResult LoadPackage()
        {
            var testFile = TestPackage.FullName;

            string targetFramework       = TestPackage.GetSetting(EnginePackageSettings.ImageTargetFrameworkName, (string)null);
            string frameworkReference    = TestPackage.GetSetting(EnginePackageSettings.ImageTestFrameworkReference, (string)null);
            bool   skipNonTestAssemblies = TestPackage.GetSetting(EnginePackageSettings.SkipNonTestAssemblies, false);

            if (_assemblyResolver != null && !TestDomain.IsDefaultAppDomain() &&
                TestPackage.GetSetting(EnginePackageSettings.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);
            }

            _driver    = GetDriver(TestDomain, testFile, targetFramework, skipNonTestAssemblies);
            _driver.ID = TestPackage.ID;

            try
            {
                return(new TestEngineResult(_driver.Load(testFile, TestPackage.Settings)));
            }
            catch (Exception ex) when(!(ex is NUnitEngineException))
            {
                throw new NUnitEngineException("An exception occurred in the driver while loading tests.", ex);
            }
        }
示例#4
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 = new DriverService();

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

                bool skipNonTestAssemblies = subPackage.GetSetting(EnginePackageSettings.SkipNonTestAssemblies, false);

                IFrameworkDriver driver = driverService.GetDriver(testFile, skipNonTestAssemblies);
                driver.ID = TestPackage.ID;

                result.Add(driver.Load(testFile, subPackage.Settings));
                _drivers.Add(driver);
            }

            return(result);
        }
示例#5
0
 private static string LoadDriver(IFrameworkDriver driver, string testFile, TestPackage subPackage)
 {
     try
     {
         return(driver.Load(testFile, subPackage.Settings));
     }
     catch (Exception ex) when(!(ex is NUnitEngineException))
     {
         throw new NUnitEngineException("An exception occurred in the driver while loading tests.", ex);
     }
 }
示例#6
0
        public void Load(string filePath, string expectedType)
        {
            IFrameworkDriver driver = GetDriver(filePath);
            var result = XmlHelper.CreateXmlNode(driver.Load(filePath, new Dictionary <string, object>()));

            Assert.That(result.Name, Is.EqualTo("test-suite"));
            Assert.That(result.GetAttribute("type"), Is.EqualTo(expectedType));
            Assert.That(result.GetAttribute("id"), Is.EqualTo(EXPECTED_ID));
            Assert.That(result.GetAttribute("name"), Is.EqualTo(filePath));
            Assert.That(result.GetAttribute("fullname"), Is.EqualTo(Path.GetFullPath(filePath)));
            Assert.That(result.GetAttribute("runstate"), Is.EqualTo(_expectedRunState));
            Assert.That(result.GetAttribute("testcasecount"), Is.EqualTo("0"));
            Assert.That(GetSkipReason(result), Is.EqualTo(_expectedReason));
            Assert.That(result.SelectNodes("test-suite").Count, Is.EqualTo(0), "Load result should not have child tests");
        }
        /// <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>
        /// 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);
        }
示例#9
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);
        }
示例#10
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;
            List <TestEngineResult> loadResults = new List <TestEngineResult>();

            foreach (string testFile in package.TestFiles)
            {
                // TODO: Should get the appropriate driver for the file
                IFrameworkDriver driver       = Services.DriverFactory.GetDriver(TestDomain, testFile, package.Settings);
                TestEngineResult driverResult = driver.Load();

                loadResults.Add(driverResult);

                if (!driverResult.HasErrors)
                {
                    drivers.Add(driver);
                }
            }

            return(MakePackageResult(loadResults));
        }