public ResultSummary Run(object fixture, SpecificationConfig specificationConfig)
        {
            var source = string.IsNullOrEmpty(specificationConfig.BaseInputDirectory)
                ? (Source)new EmbeddedResourceSource(fixture.GetType().Assembly)
                : new FileSource(fixture.GetType().Assembly, specificationConfig.BaseInputDirectory);

            var target = new FileTarget(specificationConfig.BaseOutputDirectory);

            var testSummary = new SummarizingResultRecorder();
            var anySpecExecuted = false;

            var fileExtensions = specificationConfig.SpecificationFileExtensions;
            foreach (var fileExtension in fileExtensions)
            {
                var specLocator = new ClassNameBasedSpecificationLocator(fileExtension);
                var specResource = specLocator.locateSpecification(fixture);
                if (source.canFind(specResource))
                {
                    var fixtureResult = RunSingleSpecification(fixture, source, specLocator, target, specificationConfig);
                    AddToTestResults(fixtureResult, testSummary);
                    anySpecExecuted = true;
                }
            }
            if (anySpecExecuted) return testSummary;

            throw new InvalidOperationException(string.Format("no specification extensions defined for: {0}", specificationConfig));
        }
예제 #2
0
        public void WithTargetDirectory(string baseOutputDirectory)
        {
            if (m_InTestRun)
            {
                return;
            }

            m_InTestRun = true;

            try
            {
                var reportFilePath = baseOutputDirectory +
                                     "\\Concordion\\Spec\\Concordion\\Configuration\\BaseOutputDirectory.html";
                if (File.Exists(reportFilePath))
                {
                    File.Delete(reportFilePath);
                }
                var specificationConfig = new SpecificationConfig().Load(this.GetType().Assembly);
                specificationConfig.BaseOutputDirectory = baseOutputDirectory;
                var testRunner = new DefaultConcordionRunner();
                var testResult = testRunner.Run(this, specificationConfig);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception during test execution: {0}", e);
            }
            finally
            {
                m_InTestRun = false;
            }
        }
        public bool DirectoryBasedExecuted(string baseInputDirectory)
        {
            if (m_InTestRun)
            {
                return(true);
            }

            m_InTestRun = true;

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

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

            specificationConfig.BaseInputDirectory = baseInputDirectory;
            var testRunner = new DefaultConcordionRunner();
            var testResult = testRunner.Run(this, specificationConfig);

            m_InTestRun = false;

            return(testResult.getFailureCount() == 0 && !testResult.hasExceptions());
        }
예제 #4
0
        public ResultSummary Run(object fixture, SpecificationConfig specificationConfig)
        {
            var source = string.IsNullOrEmpty(specificationConfig.BaseInputDirectory)
                ? (Source) new EmbeddedResourceSource(fixture.GetType().Assembly)
                : new FileSource(fixture.GetType().Assembly, specificationConfig.BaseInputDirectory);

            var target = new FileTarget(specificationConfig.BaseOutputDirectory);

            var testSummary     = new SummarizingResultRecorder();
            var anySpecExecuted = false;

            var fileExtensions = specificationConfig.SpecificationFileExtensions;

            foreach (var fileExtension in fileExtensions)
            {
                var specLocator  = new ClassNameBasedSpecificationLocator(fileExtension);
                var specResource = specLocator.locateSpecification(fixture);
                if (source.canFind(specResource))
                {
                    var fixtureResult = RunSingleSpecification(fixture, source, specLocator, target, specificationConfig);
                    AddToTestResults(fixtureResult, testSummary);
                    anySpecExecuted = true;
                }
            }
            if (anySpecExecuted)
            {
                return(testSummary);
            }

            throw new InvalidOperationException(string.Format("no specification extensions defined for: {0}", specificationConfig));
        }
 private SpecificationConfig GetConfig(object fixture)
 {
     SpecificationConfig result;
     var fixtureAssembly = fixture.GetType().Assembly;
     FixtureAssemplies.TryGetValue(fixtureAssembly, out result);
     if (result == null)
     {
         result = new SpecificationConfig().Load(fixtureAssembly);
         FixtureAssemplies.Add(fixtureAssembly, result);
     }
     return result;
 }
예제 #6
0
        private SpecificationConfig GetConfig(object fixture)
        {
            SpecificationConfig result;
            var fixtureAssembly = fixture.GetType().Assembly;

            FixtureAssemplies.TryGetValue(fixtureAssembly, out result);
            if (result == null)
            {
                result = new SpecificationConfig().Load(fixtureAssembly);
                FixtureAssemplies.Add(fixtureAssembly, result);
            }
            return(result);
        }
        private ResultSummary RunSingleSpecification(object fixture, Source source, 
            SpecificationLocator specificationLocator, Target target, SpecificationConfig specificationConfig)
        {
            var concordionExtender = new ConcordionBuilder();
            concordionExtender
                .withIOUtil(new IOUtil())
                .withSource(source)
                .withTarget(target)
                .withSpecificationLocator(specificationLocator)
                .withEvaluatorFactory(new BridgingEvaluatorFactory());
            var extensionLoader = new ExtensionLoader(specificationConfig);
            extensionLoader.AddExtensions(fixture, concordionExtender);

            var concordion = concordionExtender.build();
            return concordion.process(specificationLocator.locateSpecification(fixture), fixture);
        }
        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);
        }
        public bool EmbeddedExecuted()
        {
            if (m_InTestRun)
            {
                return(true);
            }

            m_InTestRun = true;

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

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

            m_InTestRun = false;

            bool hasFailures   = testResult.getFailureCount() == 0;
            bool hasExceptions = !testResult.hasExceptions();

            return(hasFailures && hasExceptions);
        }
        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);
        }
예제 #11
0
        private void GetInputOutputDirectories(IAssemblyInfo assembly)
        {
            var config = new SpecificationConfig().Load(assembly.Resolve(false));

            var baseInputDirectoryInfo = new DirectoryInfo(config.BaseInputDirectory);

            if (baseInputDirectoryInfo.Exists)
            {
            }
            else
            {
                TestModel.AddAnnotation(new Annotation(AnnotationType.Error, assembly, String.Format("The Base Input Directory {0} does not exist, reverting to default", config.BaseInputDirectory)));
            }

            var baseOutputDirectoryInfo = new DirectoryInfo(config.BaseOutputDirectory);

            this._baseOutputDirectory = baseOutputDirectoryInfo;

            if (!_baseOutputDirectory.Exists)
            {
                Directory.CreateDirectory(_baseOutputDirectory.FullName);
            }
        }
예제 #12
0
 public ExtensionLoader(SpecificationConfig configuration)
 {
     this.Configuration = configuration;
 }
 public ExtensionConfigurationTest()
 {
     this.Configuration = new SpecificationConfig();
 }
예제 #14
0
 public ExtensionLoader(SpecificationConfig configuration)
 {
     this.Configuration = configuration;
 }
예제 #15
0
        private ResultSummary RunSingleSpecification(object fixture, Source source,
                                                     SpecificationLocator specificationLocator, Target target, SpecificationConfig specificationConfig)
        {
            var concordionExtender = new ConcordionBuilder();

            concordionExtender
            .withIOUtil(new IOUtil())
            .withSource(source)
            .withTarget(target)
            .withSpecificationLocator(specificationLocator)
            .withEvaluatorFactory(new BridgingEvaluatorFactory());
            var extensionLoader = new ExtensionLoader(specificationConfig);

            extensionLoader.AddExtensions(fixture, concordionExtender);

            var concordion = concordionExtender.build();

            return(concordion.process(specificationLocator.locateSpecification(fixture), fixture));
        }