public Feature Parse(TextReader featureFileReader) { var language = this.DetermineLanguage(); var gherkinParser = new Gherkin.Parser(); try { Gherkin.Ast.GherkinDocument gherkinDocument = gherkinParser.Parse( new Gherkin.TokenScanner(featureFileReader), new Gherkin.TokenMatcher(new CultureAwareDialectProvider(language))); Feature result = new Mapper(this.configuration, gherkinDocument.Feature.Language).MapToFeature(gherkinDocument); result = this.RemoveFeatureWithExcludeTags(result); if (result != null) { this.descriptionProcessor.Process(result); } return(result); } catch (Gherkin.CompositeParserException exception) { throw new FeatureParseException("Unable to parse feature", exception); } }
public async Task ExecuteScenario_Executes_Background_Steps_First() { var gherkinFeaure = new GherkinFeatureBuilder() .WithBackground(sb => sb .Given("given background", null) .When("when background", null) .Then("then background", null)) .WithScenario("test scenario", sb => sb .Then("step one", null)) .Build(); var gherkinDocument = new Gherkin.Ast.GherkinDocument(gherkinFeaure, new Gherkin.Ast.Comment[0]); _featureFileRepository.Setup(r => r.GetByFilePath($"{nameof(FeatureWithBackgroundSteps)}.feature")) .Returns(new FeatureFile(gherkinDocument)) .Verifiable(); var featureInstance = new FeatureWithBackgroundSteps(); var output = new Mock <ITestOutputHelper>(); featureInstance.InternalOutput = output.Object; //act. await _sut.ExecuteScenarioAsync(featureInstance, "test scenario"); //assert. _featureFileRepository.Verify(); Assert.Equal("abcd", featureInstance.OrderValidator); output.Verify(o => o.WriteLine($"Given given background: PASSED"), Times.Once); output.Verify(o => o.WriteLine($"When when background: PASSED"), Times.Once); output.Verify(o => o.WriteLine($"Then then background: PASSED"), Times.Once); output.Verify(o => o.WriteLine($"Then step one: PASSED"), Times.Once); }
public Feature Parse(TextReader featureFileReader) { var language = this.DetermineLanguage(); var gherkinParser = new Gherkin.Parser(); var dialectProvider = this.GetDialectProvider(language); try { Gherkin.Ast.GherkinDocument gherkinDocument = gherkinParser.Parse( new Gherkin.TokenScanner(featureFileReader), new Gherkin.TokenMatcher(dialectProvider)); var languageServices = this.languageServicesRegistry.GetLanguageServicesForLanguage(gherkinDocument.Feature.Language); Feature result = new FileMapper(this.configuration, languageServices).MapToFeature(gherkinDocument); result = new FeatureFilter(result, this.configuration.ExcludeTags).ExcludeScenariosByTags(); if (result != null) { this.descriptionProcessor.Process(result); } return(result); } catch (Gherkin.CompositeParserException exception) { throw new FeatureParseException("Unable to parse feature", exception); } }
public void Ctor_Initializes_Properties() { //arrange. var gherkinDocument = new Gherkin.Ast.GherkinDocument(null, null); //act. var sut = new FeatureFile(gherkinDocument); //assert. Assert.Same(gherkinDocument, sut.GherkinDocument); }
public Feature Parse(TextReader featureFileReader) { var language = this.DetermineLanguage(); var gherkinParser = new Gherkin.Parser(); Gherkin.Ast.GherkinDocument gherkinDocument = gherkinParser.Parse( new Gherkin.TokenScanner(featureFileReader), new Gherkin.TokenMatcher(language)); Feature result = new Mapper(this.configuration, gherkinDocument.Feature.Language).MapToFeature(gherkinDocument); return(result); }