コード例 #1
0
		public IEnumerable<Shared.Results.TestResult> Execute(Options options)
		{
            var package = createPackage(options);
            using (var testRunner = new DefaultTestRunnerFactory().MakeTestRunner(package))
            {
                return runTests(options, package, testRunner);
            }
		}
コード例 #2
0
 public void Parse()
 {
     var options = new Options(
             _runnerSettings.Assembly.Assembly,
             getCategories(),
             getTests()
         );
     _options.Add(options);
 }
コード例 #3
0
        private IEnumerable<Shared.Results.TestResult> runTests(Options options, TestPackage package, TestRunner testRunner)
        {
            testRunner.Load(package);
            if (testRunner.Test == null)
            {
                testRunner.Unload();
                return new[] { ErrorHandler.GetError("NUnit", "Unable to locate fixture") };
            }

            var harvester = new TestHarvester(_channel);
            var testFilter = getTestFilter(options);
            string savedDirectory = Environment.CurrentDirectory;
            var result = run(testRunner, harvester, testFilter, savedDirectory);

            if (result != null)
                return harvester.Results;
            return harvester.Results;
        }
コード例 #4
0
        private TestFilter getTestFilter(Options options)
        {
            TestFilter testFilter = TestFilter.Empty;
            if (options.Tests != null && options.Tests != string.Empty)
                testFilter = new SimpleNameFilter(options.Tests);

            if (options.Categories != null && options.Categories != string.Empty)
            {
                TestFilter excludeFilter = new NotFilter(new CategoryExpression(options.Categories).Filter);
                if (testFilter.IsEmpty)
                    testFilter = excludeFilter;
                else if (testFilter is AndFilter)
                    ((AndFilter)testFilter).Add(excludeFilter);
                else
                    testFilter = new AndFilter(testFilter, excludeFilter);
            }

            if (testFilter is NotFilter)
                ((NotFilter)testFilter).TopLevel = true;
            return testFilter;
        }
コード例 #5
0
        private TestFilter getTestFilter(Options options)
        {
            var testFilter = TestFilter.Empty;
            if (!string.IsNullOrEmpty(options.Tests))
                testFilter = new SimpleNameFilter(options.Tests);

            if (!string.IsNullOrEmpty(options.Categories))
            {
                TestFilter excludeFilter = new NotFilter(new CategoryExpression(options.Categories).Filter);
                if (testFilter.IsEmpty)
                    testFilter = excludeFilter;
                else if (testFilter is AndFilter)
                    ((AndFilter)testFilter).Add(excludeFilter);
                else
                    testFilter = new AndFilter(testFilter, excludeFilter);
            }

            var notFilter = testFilter as NotFilter;
            if (notFilter != null)
                notFilter.TopLevel = true;
            return testFilter;
        }
コード例 #6
0
        private TestPackage createPackage(Options options)
        {
            const ProcessModel processModel = ProcessModel.Default;
            
            var package = new TestPackage(options.Assembly);
            var domainUsage = DomainUsage.Single;
			package.TestName = null;
            
            package.Settings["ProcessModel"] = processModel;
            package.Settings["DomainUsage"] = domainUsage;
            //if (framework != null)
            //package.Settings["RuntimeFramework"] = Environment.Version.ToString();
            
            //TODO GFY THIS IS ALWAYS FALSE
            if (domainUsage == DomainUsage.None)
                CoreExtensions.Host.AddinRegistry = Services.AddinRegistry;

            package.Settings["ShadowCopyFiles"] = false;
			package.Settings["UseThreadedRunner"] = false;
            package.Settings["DefaultTimeout"] = 0;

            return package;
		}