Beispiel #1
0
        public SpecFlowConfiguration LoadConfiguration(SpecFlowConfiguration specFlowConfiguration)
        {
            ConfigurationSectionHandler section = GetSection();

            var runtimeConfigurationLoader = new AppConfigConfigurationLoader();

            return(runtimeConfigurationLoader.LoadAppConfig(specFlowConfiguration, section));
        }
Beispiel #2
0
        public void Check_Trace_minTracedDuration()
        {
            string config = @"<specflow><trace minTracedDuration=""0:0:1.0"" /></specflow>";

            var configSection = ConfigurationSectionHandler.CreateFromXml(config);

            var runtimeConfig = new AppConfigConfigurationLoader().LoadAppConfig(ConfigurationLoader.GetDefault(), configSection);

            runtimeConfig.MinTracedDuration.Should().Be(TimeSpan.FromSeconds(1));
        }
Beispiel #3
0
        public void Check_Trace_traceTimings_as_False()
        {
            string config = @"<specflow><trace traceTimings=""false"" /></specflow>";

            var configSection = ConfigurationSectionHandler.CreateFromXml(config);

            var runtimeConfig = new AppConfigConfigurationLoader().LoadAppConfig(ConfigurationLoader.GetDefault(), configSection);

            runtimeConfig.TraceTimings.Should().BeFalse();
        }
Beispiel #4
0
        public void Check_Trace_StepDefinitionSkeletonStyle_MethodNameUnderscores()
        {
            string config = @"<specflow><trace stepDefinitionSkeletonStyle=""MethodNameUnderscores"" /></specflow>";

            var configSection = ConfigurationSectionHandler.CreateFromXml(config);

            var runtimeConfig = new AppConfigConfigurationLoader().LoadAppConfig(ConfigurationLoader.GetDefault(), configSection);

            runtimeConfig.StepDefinitionSkeletonStyle.Should().Be(StepDefinitionSkeletonStyle.MethodNameUnderscores);
        }
Beispiel #5
0
        public void Check_Plugins_NotInConfigFile()
        {
            string config = @"<specflow></specflow>";

            var configSection = ConfigurationSectionHandler.CreateFromXml(config);

            var runtimeConfig = new AppConfigConfigurationLoader().LoadAppConfig(ConfigurationLoader.GetDefault(), configSection);

            runtimeConfig.Plugins.Should().BeEmpty();
        }
Beispiel #6
0
        public void Check_Trace_traceSuccessfulSteps_as_True()
        {
            string config = @"<specflow><trace traceSuccessfulSteps=""true"" /></specflow>";

            var configSection = ConfigurationSectionHandler.CreateFromXml(config);

            var runtimeConfig = new AppConfigConfigurationLoader().LoadAppConfig(ConfigurationLoader.GetDefault(), configSection);

            runtimeConfig.TraceSuccessfulSteps.Should().BeTrue();
        }
Beispiel #7
0
        public void CheckBindingCulture()
        {
            string config = @"<specflow><bindingCulture name=""de"" /></specflow>";

            var configSection = ConfigurationSectionHandler.CreateFromXml(config);

            var runtimeConfig = new AppConfigConfigurationLoader().LoadAppConfig(ConfigurationLoader.GetDefault(), configSection);

            runtimeConfig.BindingCulture.TwoLetterISOLanguageName.Should().Be("de");
        }
Beispiel #8
0
        public void Check_StepAssemblies_IsEmpty()
        {
            string config = @"<specflow><stepAssemblies /></specflow>";

            var configSection = ConfigurationSectionHandler.CreateFromXml(config);

            var runtimeConfig = new AppConfigConfigurationLoader().LoadAppConfig(ConfigurationLoader.GetDefault(), configSection);

            runtimeConfig.AdditionalStepAssemblies.Should().BeEmpty();
        }
Beispiel #9
0
        public void CheckUnitTestProvider()
        {
            string config = @"<specflow><unitTestProvider name=""XUnit"" /></specflow>";

            var configSection = ConfigurationSectionHandler.CreateFromXml(config);

            var runtimeConfig = new AppConfigConfigurationLoader().LoadAppConfig(ConfigurationLoader.GetDefault(), configSection);

            runtimeConfig.UnitTestProvider.Should().Be("XUnit");
        }
Beispiel #10
0
        public void Check_Runtime_stopAtFirstError_as_true()
        {
            string config = @"<specflow><runtime stopAtFirstError=""true"" /></specflow>";

            var configSection = ConfigurationSectionHandler.CreateFromXml(config);

            var runtimeConfig = new AppConfigConfigurationLoader().LoadAppConfig(ConfigurationLoader.GetDefault(), configSection);

            runtimeConfig.StopAtFirstError.Should().BeTrue();
        }
Beispiel #11
0
        public void Check_Trace_StepDefinitionSkeletonStyle_RegexAttribute()
        {
            string config = @"<specflow><trace stepDefinitionSkeletonStyle=""RegexAttribute"" /></specflow>";

            var configSection = ConfigurationSectionHandler.CreateFromXml(config);

            var runtimeConfig = new AppConfigConfigurationLoader().LoadAppConfig(ConfigurationLoader.GetDefault(), configSection);

            runtimeConfig.StepDefinitionSkeletonStyle.Should().Be(StepDefinitionSkeletonStyle.RegexAttribute);
        }
Beispiel #12
0
        public void Check_Runtime_missingOrPendingStepsOutcome_as_Inconclusive()
        {
            string config = @"<specflow><runtime missingOrPendingStepsOutcome=""Inconclusive"" /></specflow>";

            var configSection = ConfigurationSectionHandler.CreateFromXml(config);

            var runtimeConfig = new AppConfigConfigurationLoader().LoadAppConfig(ConfigurationLoader.GetDefault(), configSection);

            runtimeConfig.MissingOrPendingStepsOutcome.Should().Be(MissingOrPendingStepsOutcome.Inconclusive);
        }
Beispiel #13
0
        public void Check_Plugins_Parameters()
        {
            string config = @"<specflow><plugins><add name=""testEntry"" parameters=""pluginParameter""/></plugins></specflow>";

            var configSection = ConfigurationSectionHandler.CreateFromXml(config);

            var runtimeConfig = new AppConfigConfigurationLoader().LoadAppConfig(ConfigurationLoader.GetDefault(), configSection);

            runtimeConfig.Plugins.Count.Should().Be(1);
            runtimeConfig.Plugins.First().Parameters.Should().Be("pluginParameter");
        }
Beispiel #14
0
        public void Check_Plugins_PluginType_GeneratorAndRuntime()
        {
            string config = @"<specflow><plugins><add name=""testEntry"" type=""GeneratorAndRuntime""/></plugins></specflow>";

            var configSection = ConfigurationSectionHandler.CreateFromXml(config);

            var runtimeConfig = new AppConfigConfigurationLoader().LoadAppConfig(ConfigurationLoader.GetDefault(), configSection);

            runtimeConfig.Plugins.Count.Should().Be(1);
            runtimeConfig.Plugins.First().Type.Should().Be(PluginType.GeneratorAndRuntime);
        }
Beispiel #15
0
        public void CanLoadConfigFromString(string configString)
        {
            var runtimeConfig = ConfigurationLoader.GetDefault();

            var configurationLoader = new AppConfigConfigurationLoader();


            var configurationSectionHandler = ConfigurationSectionHandler.CreateFromXml(configString);

            configurationLoader.LoadAppConfig(runtimeConfig, configurationSectionHandler);
        }
Beispiel #16
0
        public void Check_StepAssemblies_OneEntry()
        {
            string config = @"<specflow><stepAssemblies><stepAssembly assembly=""testEntry""/></stepAssemblies></specflow>";

            var configSection = ConfigurationSectionHandler.CreateFromXml(config);

            var runtimeConfig = new AppConfigConfigurationLoader().LoadAppConfig(ConfigurationLoader.GetDefault(), configSection);

            runtimeConfig.AdditionalStepAssemblies.Count.Should().Be(1);
            runtimeConfig.AdditionalStepAssemblies.First().Should().Be("testEntry");
        }
Beispiel #17
0
        public void Check_CucumberMessages_NotConfigured_EnabledIsFalse()
        {
            string config = @"<specflow>
                            </specflow>";

            var configSection = ConfigurationSectionHandler.CreateFromXml(config);

            var runtimeConfig = new AppConfigConfigurationLoader().LoadAppConfig(ConfigurationLoader.GetDefault(), configSection);

            runtimeConfig.CucumberMessagesConfiguration.Enabled.Should().BeFalse();
        }
Beispiel #18
0
        public void Check_Plugins_TwoSameNameEntry()
        {
            string config = @"<specflow><plugins>
                                <add name=""testEntry""/>
                                <add name=""testEntry""/>
                              </plugins></specflow>";

            var configSection = ConfigurationSectionHandler.CreateFromXml(config);

            var runtimeConfig = new AppConfigConfigurationLoader().LoadAppConfig(ConfigurationLoader.GetDefault(), configSection);

            runtimeConfig.Plugins.Count.Should().Be(1);
            runtimeConfig.Plugins[0].Name.Should().Be("testEntry");
        }
Beispiel #19
0
        public SpecFlowConfiguration LoadConfiguration(SpecFlowConfiguration specFlowConfiguration)
        {
            if (IsJsonConfig)
            {
                var jsonConfigurationLoader = new JsonConfigurationLoader();

                return(jsonConfigurationLoader.LoadJson(specFlowConfiguration, configFileContent));
            }

            ConfigurationSectionHandler section = GetSection();

            var runtimeConfigurationLoader = new AppConfigConfigurationLoader();

            return(runtimeConfigurationLoader.LoadAppConfig(specFlowConfiguration, section));
        }
Beispiel #20
0
        public void Check_CucumberMessages_Sinks_EmptyList()
        {
            string config = @"<specflow>
                                <cucumber-messages enabled=""false"">
                                    <sinks>
                                    </sinks>
                                </cucumber-messages>
                            </specflow>";

            var configSection = ConfigurationSectionHandler.CreateFromXml(config);

            var runtimeConfig = new AppConfigConfigurationLoader().LoadAppConfig(ConfigurationLoader.GetDefault(), configSection);

            runtimeConfig.CucumberMessagesConfiguration.Sinks.Should().BeEmpty();
        }
Beispiel #21
0
        public void Check_Trace_Listener()
        {
            string config = @"<specflow><trace listener=""TraceListener"" /></specflow>";

            var configSection = ConfigurationSectionHandler.CreateFromXml(config);

            var runtimeConfig = new AppConfigConfigurationLoader().LoadAppConfig(ConfigurationLoader.GetDefault(), configSection);

            runtimeConfig.CustomDependencies.Count.Should().Be(1);

            foreach (ContainerRegistrationConfigElement containerRegistrationConfigElement in runtimeConfig.CustomDependencies)
            {
                containerRegistrationConfigElement.Implementation.Should().Be("TraceListener");
            }
        }
        public void AddFromXmlSpecFlowSection(string specFlowSection)
        {
            ProjectBuilder project       = _solutionDriver.DefaultProject;
            var            configSection = ConfigurationSectionHandler.CreateFromXml(specFlowSection);
            var            appConfigConfigurationLoader = new AppConfigConfigurationLoader();

            var specFlowConfiguration = appConfigConfigurationLoader.LoadAppConfig(ConfigurationLoader.GetDefault(), configSection);

            foreach (string stepAssemblyName in specFlowConfiguration.AdditionalStepAssemblies)
            {
                _configurationDriver.AddStepAssembly(new StepAssembly(stepAssemblyName));
            }

            _configurationDriver.SetBindingCulture(project, specFlowConfiguration.BindingCulture);
            _configurationDriver.SetFeatureLanguage(project, specFlowConfiguration.FeatureLanguage);
        }
Beispiel #23
0
        public void Check_CucumberMessages_Sinks_ListOneEntry()
        {
            string config = @"<specflow>
                                <cucumber-messages enabled=""false"">
                                    <sinks>
                                        <sink type=""file"" path=""C:\temp\testrun.cm"" />
                                    </sinks>
                                </cucumber-messages>
                            </specflow>";

            var configSection = ConfigurationSectionHandler.CreateFromXml(config);

            var runtimeConfig = new AppConfigConfigurationLoader().LoadAppConfig(ConfigurationLoader.GetDefault(), configSection);

            runtimeConfig.CucumberMessagesConfiguration.Sinks.Count.Should().Be(1);
        }
Beispiel #24
0
        public void CanLoadConfigWithParallelCodeGenerationOptionsFromString(string configString)
        {
            var specFlowConfiguration = ConfigurationLoader.GetDefault();

            var configurationLoader = new AppConfigConfigurationLoader();


            var configurationSectionHandler = ConfigurationSectionHandler.CreateFromXml(configString);

            specFlowConfiguration = configurationLoader.LoadAppConfig(specFlowConfiguration, configurationSectionHandler);



            Assert.IsTrue(specFlowConfiguration.MarkFeaturesParallelizable);
            Assert.IsNotEmpty(specFlowConfiguration.SkipParallelizableMarkerForTags);
            Assert.Contains("mySpecialTag1", specFlowConfiguration.SkipParallelizableMarkerForTags);
            Assert.Contains("mySpecialTag2", specFlowConfiguration.SkipParallelizableMarkerForTags);
        }
Beispiel #25
0
        public void CanLoadConfigWithNonParallelizableTagsProvided()
        {
            var config =
                @"<specFlow>
                    <generator>
                        <addNonParallelizableMarkerForTags>
                            <tag value=""tag1""/>
                            <tag value=""tag2""/>
                        </addNonParallelizableMarkerForTags>
                    </generator>
                </specFlow>";
            var specFlowConfiguration = ConfigurationLoader.GetDefault();
            var configurationLoader   = new AppConfigConfigurationLoader();

            var configurationSectionHandler = ConfigurationSectionHandler.CreateFromXml(config);

            specFlowConfiguration = configurationLoader.LoadAppConfig(specFlowConfiguration, configurationSectionHandler);

            specFlowConfiguration.AddNonParallelizableMarkerForTags.Should().BeEquivalentTo("tag1", "tag2");
        }
Beispiel #26
0
        public SpecFlowConfiguration Load(SpecFlowConfiguration specFlowConfiguration)
        {
            if (_configFilePath == null)
            {
                return(LoadDefaultConfiguration(specFlowConfiguration));
            }

            var extension         = Path.GetExtension(_configFilePath);
            var configFileContent = File.ReadAllText(_configFilePath);

            switch (extension.ToLowerInvariant())
            {
            case ".config":
            {
                var configDocument = new XmlDocument();
                configDocument.LoadXml(configFileContent);
                var specFlowNode = configDocument.SelectSingleNode("/configuration/specFlow");
                if (specFlowNode == null)
                {
                    return(LoadDefaultConfiguration(specFlowConfiguration));
                }

                var configSection = ConfigurationSectionHandler.CreateFromXml(specFlowNode);
                var loader        = new AppConfigConfigurationLoader();
                return(loader.LoadAppConfig(specFlowConfiguration, configSection));
            }

            case ".json":
            {
                if (_jsonSpecFlow2Mode)
                {
                    configFileContent = ConvertToJsonSpecFlow2Style(configFileContent);
                }

                var loader = new JsonConfigurationLoader();
                return(loader.LoadJson(specFlowConfiguration, configFileContent));
            }
            }
            throw new ConfigurationErrorsException($"Invalid config type: {_configFilePath}");
        }
 public ConfigurationLoader()
 {
     _jsonConfigurationLoader      = new JsonConfigurationLoader();
     _appConfigConfigurationLoader = new AppConfigConfigurationLoader();
 }
 public XmlConfigurationParserDriver(AppConfigConfigurationLoader appConfigConfigurationLoader)
 {
     _appConfigConfigurationLoader = appConfigConfigurationLoader;
 }
 public ConfigurationLoader(ISpecFlowJsonLocator specFlowJsonLocator)
 {
     _specFlowJsonLocator          = specFlowJsonLocator;
     _jsonConfigurationLoader      = new JsonConfigurationLoader();
     _appConfigConfigurationLoader = new AppConfigConfigurationLoader();
 }