コード例 #1
0
        private void ExecuteTestAssembly(TestAssembly testAssembly)
        {
            this.TestListeners.BeforeAssembly(testAssembly);

            // run assemblysetup
            System.Runtime.CompilerServices.RuntimeHelpers.PrepareConstrainedRegions();
            try
            {
                if (this.RunAssemblySetUp(testAssembly))
                {
                    foreach (IFixture fixture in testAssembly.Fixtures)
                    {
                        using (FixtureRunner runner =
                                   new FixtureRunner(
                                       fixture,
                                       testAssembly.GetTestCasesFromFixture(fixture),
                                       this.TestListeners)
                               )
                        {
                            runner.Run();
                        }
                        // collect GC
                        GC.WaitForPendingFinalizers();
                        GC.Collect();
                    }
                }
            }
            finally
            {
                // run assembly teardown
                this.RunAssemblyTearDown(testAssembly);
                this.TestListeners.AfterAssembly(testAssembly);
            }
        }
コード例 #2
0
        public override TestResult Run(EventListener listener, ITestFilter filter)
        {
            listener.TestStarted(this.TestName);

            Fixture = Reflect.Construct(m_FixtureType);
            RunFixtureSetUp();
            var fixtureRunner    = new FixtureRunner();
            var concordionResult = fixtureRunner.Run(Fixture);
            var testResult       = NUnitTestResult(concordionResult, fixtureRunner.ResultPath);

            RunFixtureTearDown();

            listener.TestFinished(testResult);

            return(testResult);
        }
コード例 #3
0
        public bool EmbeddedExecuted()
        {
            if (m_InTestRun)
            {
                return(true);
            }

            m_InTestRun = true;

            var specificationConfig = new SpecificationConfig().Load(this.GetType());

            specificationConfig.BaseInputDirectory = null;
            var fixtureRunner = new FixtureRunner(specificationConfig);
            var testResult    = fixtureRunner.Run(this);

            m_InTestRun = false;

            return(!testResult.HasFailures && !testResult.HasExceptions);
        }
コード例 #4
0
        /// <summary>
        /// Perform the validation run, mark of any issues and return issues as well as analytics.
        /// </summary>
        /// <param name="currentAssembly">An assembly to pickup fixtures and templates from</param>
        /// <returns>
        /// The details of each validator fixture, template and instance which were checked
        /// </returns>
        public ValidatorRunResult Run(Assembly currentAssembly)
        {
            var validatorRunResult = new ValidatorRunResult();

            validatorRunResult.RunDate                = _dateToRun;
            validatorRunResult.ShouldReport           = true;
            validatorRunResult.SummaryAtFixtureLevel  = new ResultSummary();
            validatorRunResult.SummaryAtTemplateLevel = new ResultSummary();
            validatorRunResult.SummaryAtInstanceLevel = new ResultSummary();
            validatorRunResult.FixtureResults         = new List <ValidatorFixtureResult>();

            try
            {
                foreach (var validatorFixtureInfo in currentAssembly.DefinedTypes.Where(ValidatorFixtureAttribute.HasAttribute))
                {
                    var validatorFixtureRunner = new FixtureRunner(_environ, validatorFixtureInfo);
                    var validatorFixtureResult = validatorFixtureRunner.Run();
                    validatorRunResult.AddFixtureResult(validatorFixtureResult);
                }
            }
            catch (Exception e)
            {
                validatorRunResult.Error = e;
            }

            if (validatorRunResult.Error != null)
            {
                validatorRunResult.Status = GroupStatus.Error;
            }
            else if (validatorRunResult.SummaryAtFixtureLevel.Failure > 0)
            {
                validatorRunResult.Status = GroupStatus.Failure;
            }
            else
            {
                validatorRunResult.Status = GroupStatus.Success;
            }

            return(validatorRunResult);
        }
コード例 #5
0
        public bool DirectoryBasedExecuted(string baseInputDirectory)
        {
            if (m_InTestRun)
            {
                return(true);
            }

            m_InTestRun = true;

            //work around for bug of NUnit GUI runner
            baseInputDirectory = baseInputDirectory +
                                 Path.DirectorySeparatorChar +
                                 ".." +
                                 Path.DirectorySeparatorChar +
                                 this.GetType().Assembly.GetName().Name;

            var specificationConfig = new SpecificationConfig().Load(this.GetType());

            specificationConfig.BaseInputDirectory = baseInputDirectory;
            var fixtureRunner = new FixtureRunner(specificationConfig);
            var testResult    = fixtureRunner.Run(this);

            m_InTestRun = false;

            foreach (var failureDetail in testResult.FailureDetails)
            {
                Console.WriteLine(failureDetail.Message);
                Console.WriteLine(failureDetail.StackTrace);
            }
            foreach (var errorDetail in testResult.ErrorDetails)
            {
                Console.WriteLine(errorDetail.Message);
                Console.WriteLine(errorDetail.StackTrace);
                Console.WriteLine(errorDetail.Exception);
            }

            return(!testResult.HasFailures && !testResult.HasExceptions);
        }