How to use GherkinDocument method of Gherkin.Ast.GherkinDocument class

Best Gherkin-dotnet code snippet using Gherkin.Ast.GherkinDocument.GherkinDocument

DeveroomGherkinParser.cs

Source:DeveroomGherkinParser.cs Github

copy

Full Screen

...11{12 public class DeveroomGherkinParser13 {14 private readonly IMonitoringService _monitoringService;15 private IAstBuilder<DeveroomGherkinDocument> _astBuilder;16 public IGherkinDialectProvider DialectProvider { get; }17 internal DeveroomGherkinAstBuilder AstBuilder => _astBuilder as DeveroomGherkinAstBuilder;18 public DeveroomGherkinParser(IGherkinDialectProvider dialectProvider, IMonitoringService monitoringService)19 {20 _monitoringService = monitoringService;21 DialectProvider = dialectProvider;22 }23 public bool ParseAndCollectErrors(string featureFileContent, IDeveroomLogger logger, out DeveroomGherkinDocument gherkinDocument, out List<ParserException> parserErrors)24 {25 var reader = new StringReader(featureFileContent);26 gherkinDocument = null;27 parserErrors = new List<ParserException>();28 try29 {30 gherkinDocument = Parse(reader, "foo.feature"); //TODO: remove unused path31 return true;32 }33 catch (ParserException parserException)34 {35 logger.LogVerbose($"ParserErrors: {parserException.Message}");36 gherkinDocument = GetResultOfInvalid();37 if (parserException is CompositeParserException compositeParserException)38 parserErrors.AddRange(compositeParserException.Errors);39 else40 parserErrors.Add(parserException);41 }42 catch (Exception e)43 {44 logger.LogException(_monitoringService, e, "Exception during Gherkin parsing");45 gherkinDocument = GetResult();46 }47 return false;48 }49 private DeveroomGherkinDocument GetResultOfInvalid()50 {51 // trying to "finish" open nodes by sending dummy <endrule> messages up to 5 levels of nesting52 for (int i = 0; i < 10; i++)53 {54 var result = GetResult();55 if (result != null)56 return result;57 try58 {59 AstBuilder.EndRule(RuleType.None);60 }61 catch (Exception)62 {63 }64 }65 return null;66 }67 public DeveroomGherkinDocument Parse(TextReader featureFileReader, string sourceFilePath)68 {69 var tokenScanner = (ITokenScanner)new HotfixTokenScanner(featureFileReader);70 var tokenMatcher = new TokenMatcher(DialectProvider);71 _astBuilder = new DeveroomGherkinAstBuilder(sourceFilePath, () => tokenMatcher.CurrentDialect);72 var parser = new InternalParser(_astBuilder, AstBuilder.RecordStateForLine, _monitoringService);73 var gherkinDocument = parser.Parse(tokenScanner, tokenMatcher);74 CheckSemanticErrors(gherkinDocument);75 return gherkinDocument;76 }77 class InternalParser : Parser<DeveroomGherkinDocument>78 {79 private readonly Action<int, int> _recordStateForLine;80 private readonly IMonitoringService _monitoringService;81 public InternalParser(IAstBuilder<DeveroomGherkinDocument> astBuilder, Action<int, int> recordStateForLine, IMonitoringService monitoringService)82 : base(astBuilder)83 {84 _recordStateForLine = recordStateForLine;85 _monitoringService = monitoringService;86 }87 public int NullMatchToken(int state, Token token)88 {89 return MatchToken(state, token, new ParserContext()90 {91 Errors = new List<ParserException>(),92 TokenMatcher = new AllFalseTokenMatcher(),93 TokenQueue = new Queue<Token>(),94 TokenScanner = new NullTokenScanner()95 });96 }97 protected override int MatchToken(int state, Token token, ParserContext context)98 {99 _recordStateForLine?.Invoke(token.Location.Line, state);100 try101 {102 return base.MatchToken(state, token, context);103 }104 catch (InvalidOperationException ex)105 {106 _monitoringService.MonitorError(ex);107 throw;108 }109 }110 }111 public DeveroomGherkinDocument GetResult()112 {113 return _astBuilder.GetResult();114 }115 #region Semantic Errors116 protected virtual void CheckSemanticErrors(DeveroomGherkinDocument specFlowDocument)117 {118 var errors = new List<ParserException>();119 errors.AddRange(((DeveroomGherkinAstBuilder)_astBuilder).Errors);120 if (specFlowDocument?.Feature != null)121 {122 CheckForDuplicateScenarios(specFlowDocument.Feature, errors);123 CheckForDuplicateExamples(specFlowDocument.Feature, errors);124 CheckForMissingExamples(specFlowDocument.Feature, errors);125 CheckForRulesPreSpecFlow31(specFlowDocument.Feature, errors);126 }127 // collect128 if (errors.Count == 1)129 throw errors[0];130 if (errors.Count > 1)131 throw new CompositeParserException(errors.ToArray());132 }133 private void CheckForRulesPreSpecFlow31(Feature feature, List<ParserException> errors)134 {135 //TODO: Show error when Rule keyword is used in SpecFlow v3.0 or earlier136 }137 private void CheckForDuplicateScenarios(Feature feature, List<ParserException> errors)138 {139 // duplicate scenario name140 var duplicatedScenarios = feature.FlattenScenarioDefinitions().GroupBy(sd => sd.Name, sd => sd).Where(g => g.Count() > 1).ToArray();141 errors.AddRange(142 duplicatedScenarios.Select(g =>143 new SemanticParserException(144 $"Feature file already contains a scenario with name '{g.Key}'",145 g.ElementAt(1).Location)));146 }147 private void CheckForDuplicateExamples(Feature feature, List<ParserException> errors)148 {149 foreach (var scenarioOutline in feature.FlattenScenarioDefinitions().OfType<ScenarioOutline>())150 {151 var duplicateExamples = scenarioOutline.Examples152 .Where(e => !String.IsNullOrWhiteSpace(e.Name))153 .Where(e => e.Tags.All(t => t.Name != "ignore"))154 .GroupBy(e => e.Name, e => e).Where(g => g.Count() > 1);155 foreach (var duplicateExample in duplicateExamples)156 {157 var message = $"Scenario Outline '{scenarioOutline.Name}' already contains an example with name '{duplicateExample.Key}'";158 var semanticParserException = new SemanticParserException(message, duplicateExample.ElementAt(1).Location);159 errors.Add(semanticParserException);160 }161 }162 }163 private void CheckForMissingExamples(Feature feature, List<ParserException> errors)164 {165 foreach (var scenarioOutline in feature.FlattenScenarioDefinitions().OfType<ScenarioOutline>())166 {167 if (DoesntHavePopulatedExamples(scenarioOutline))168 {169 var message = $"Scenario Outline '{scenarioOutline.Name}' has no examples defined";170 var semanticParserException = new SemanticParserException(message, scenarioOutline.Location);171 errors.Add(semanticParserException);172 }173 }174 }175 private static bool DoesntHavePopulatedExamples(ScenarioOutline scenarioOutline)176 {177 return !scenarioOutline.Examples.Any() || scenarioOutline.Examples.Any(x => x.TableBody == null || !x.TableBody.Any());178 }179 #endregion180 #region Expected tokens181 class NullAstBuilder : IAstBuilder<DeveroomGherkinDocument>182 {183 public void Build(Token token)184 {185 }186 public void StartRule(RuleType ruleType)187 {188 }189 public void EndRule(RuleType ruleType)190 {191 }192 public DeveroomGherkinDocument GetResult()193 {194 return null;195 }196 public void Reset()197 {198 }199 }200 class AllFalseTokenMatcher : ITokenMatcher201 {202 public bool Match_EOF(Token token)203 {204 return false;205 }206 public bool Match_Empty(Token token)...

Full Screen

Full Screen

ScenarioTestCaseRunner.cs

Source:ScenarioTestCaseRunner.cs Github

copy

Full Screen

...21 public ScenarioTestCaseRunner(ScenarioTestCase testCase, IMessageBus messageBus, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource, TestOutputHelper testOutputHelper) : base(testCase, messageBus, aggregator, cancellationTokenSource)22 {23 this.testOutputHelper = testOutputHelper;24 }25 public void FeatureSetup(GherkinDocument gherkinDocument)26 {27 Debug.Assert(gherkinDocument.Feature != null);28 var feature = gherkinDocument.Feature;29 var assembly = Assembly.LoadFrom(TestCase.FeatureTypeInfo.SpecFlowProject.AssemblyPath);30 testRunner = TestRunnerManager.GetTestRunner(assembly);31 var featureInfo = new FeatureInfo(GetFeatureCulture(feature.Language), feature.Name, feature.Description, ProgrammingLanguage.CSharp, feature.Tags.GetTags().ToArray());32 testRunner.OnFeatureStart(featureInfo);33 }34 private CultureInfo GetFeatureCulture(string language)35 {36 var culture = new CultureInfo(language);37 if (culture.IsNeutralCulture)38 {39 return new CultureInfo("en-US"); //TODO: find the "default" specific culture for the neutral culture, like 'en-US' for 'en'. This is currently in the SpecFlow generator...

Full Screen

Full Screen

FeatureFileTests.cs

Source:FeatureFileTests.cs Github

copy

Full Screen

...8 [Fact]9 public void Ctor_Initializes_Properties()10 {11 //arrange.12 var gherkinDocument = new Gherkin.Ast.GherkinDocument(null, null);13 //act.14 var sut = new FeatureFile(gherkinDocument);15 //assert.16 Assert.Same(gherkinDocument, sut.GherkinDocument);17 }18 [Fact]19 public void GetScenario_Retrieves_If_Found()20 {21 //arrange.22 var scenarioName = "name exists";23 var sut = new FeatureFile(CreateGherkinDocumentWithScenario(scenarioName));24 //act.25 var scenario = sut.GetScenario(scenarioName);26 //assert.27 Assert.NotNull(scenario);28 Assert.Same(sut.GherkinDocument.Feature.Children.First(), scenario);29 }30 [Fact]31 public void GetScenario_Gives_Null_If_Not_Found()32 {33 //arrange.34 var sut = new FeatureFile(CreateGherkinDocumentWithScenario("existing"));35 //act.36 var scenario = sut.GetScenario("non-existing");37 //assert.38 Assert.Null(scenario);39 }40 [Fact]41 public void GetScenarioOutline_Retrieves_If_Found()42 {43 //arrange.44 var scenarioName = "name exists";45 var sut = new FeatureFile(CreateGherkinDocumentWithScenarioOutline(scenarioName));46 //act.47 var scenario = sut.GetScenarioOutline(scenarioName);48 //assert.49 Assert.NotNull(scenario);50 Assert.Same(sut.GherkinDocument.Feature.Children.First(), scenario);51 }52 [Fact]53 public void GetScenarioOutline_Gives_Null_If_Not_Found()54 {55 //arrange.56 var sut = new FeatureFile(CreateGherkinDocumentWithScenarioOutline("existing"));57 //act.58 var scenario = sut.GetScenarioOutline("non-existing");59 //assert.60 Assert.Null(scenario);61 }62 [Fact]63 public void GetBackground_Retrieves_If_Present()64 {65 var sut = new FeatureFile(CreateGherkinDocumentWithBackground());66 var background = sut.GetBackground();67 Assert.NotNull(background);68 }69 [Fact]70 public void GetBackground_Gives_Null_If_Not_Present()71 {72 var sut = new FeatureFile(CreateGherkinDocumentWithScenario("test"));73 var background = sut.GetBackground();74 Assert.Null(background);75 }76 private static Gherkin.Ast.GherkinDocument CreateGherkinDocumentWithScenario(77 string scenario,78 Gherkin.Ast.StepArgument stepArgument = null)79 {80 return new Gherkin.Ast.GherkinDocument(81 new Gherkin.Ast.Feature(new Gherkin.Ast.Tag[0], null, null, null, null, null, new Gherkin.Ast.ScenarioDefinition[]82 {83 new Gherkin.Ast.Scenario(84 new Gherkin.Ast.Tag[0],85 null,86 null,87 scenario,88 null,89 new Gherkin.Ast.Step[]{ })90 }),91 new Gherkin.Ast.Comment[0]);92 }93 private static Gherkin.Ast.GherkinDocument CreateGherkinDocumentWithBackground()94 {95 return new Gherkin.Ast.GherkinDocument(96 new Gherkin.Ast.Feature(new Gherkin.Ast.Tag[0], null, null, null, null, null, new Gherkin.Ast.ScenarioDefinition[]97 {98 new Gherkin.Ast.Background(99 null,100 null,101 null,102 null,103 new Gherkin.Ast.Step[]{ })104 }),105 new Gherkin.Ast.Comment[0]);106 }107 private static Gherkin.Ast.GherkinDocument CreateGherkinDocumentWithScenarioOutline(108 string scenario,109 Gherkin.Ast.StepArgument stepArgument = null)110 {111 return new Gherkin.Ast.GherkinDocument(112 new Gherkin.Ast.Feature(new Gherkin.Ast.Tag[0], null, null, null, null, null, new Gherkin.Ast.ScenarioDefinition[]113 {114 new Gherkin.Ast.ScenarioOutline(115 new Gherkin.Ast.Tag[0],116 null,117 null,118 scenario,119 null,120 new Gherkin.Ast.Step[]{ },121 new Gherkin.Ast.Examples[]{ })122 }),123 new Gherkin.Ast.Comment[0]);124 }125 }...

Full Screen

Full Screen

SpecFlowMetadataService.cs

Source:SpecFlowMetadataService.cs Github

copy

Full Screen

...9{10 public class SpecFlowMetadataService11 {12 private const string ExcelSearchText = "I want to construct request payload from the 'source' file'";13 private static List<ApiTestCase.TestCaseMetadata> ConstructFeatureDetails(GherkinDocument document, IFileInfo featureFile) => document.Feature.Children14 .OfType<Scenario>()15 .Select(scenario =>16 {17 var steps = scenario.Steps.Select(x => x.Text).ToList();18 var referencedExcelFile = steps.Single(x => x.StartsWith(ExcelSearchText))19 .Replace(ExcelSearchText, string.Empty)20 .Replace("", string.Empty);21 return new ApiTestCase.TestCaseMetadata22 {23 FeatureFile = featureFile,24 FeatureName = document.Feature.Name,25 FeatureTags = document.Feature.Tags.Select(x => x.Name.Replace("@", string.Empty)).ToList(),26 ScenarioName = scenario.Name,27 Tags = scenario.Tags.Select(x => x.Name.Replace("@", string.Empty)).ToList(),28 Steps = steps,29 HasExamples = scenario.Examples.Any(),30 ExcelFileName = referencedExcelFile31 };32 }).ToList();33 public List<ApiTestCase.TestCaseMetadata> ExtractSpecFlowMetadata(List<IFileInfo> featureFiles)34 {35 return featureFiles36 .SelectMany(featureFile =>37 {38 //TODO: Poly39 GherkinDocument gherkinDocument;40 try41 {42 gherkinDocument = new Parser().Parse(featureFile.FullName);43 }44 catch45 {46 Thread.Sleep(500);47 gherkinDocument = new Parser().Parse(featureFile.FullName);48 }49 return ConstructFeatureDetails(gherkinDocument, featureFile);50 })51 .ToList();52 }53 }...

Full Screen

Full Screen

GherkinEvents.cs

Source:GherkinEvents.cs Github

copy

Full Screen

...19 public IEnumerable<IEvent> iterable (SourceEvent sourceEvent)20 {21 List<IEvent> events = new List<IEvent> ();22 try {23 GherkinDocument gherkinDocument = parser.Parse (new StringReader(sourceEvent.data));24 if (printSource) {25 events.Add (sourceEvent);26 }27 if (printAst) {28 events.Add (new GherkinDocumentEvent(sourceEvent.uri, gherkinDocument));29 }30 if (printPickles) {31 throw new NotSupportedException ("Gherkin.NET doesn't have a pickle compiler yet");32 }33 } catch (CompositeParserException e) {34 foreach (ParserException error in e.Errors) {35 addErrorAttachment (events, error, sourceEvent.uri);36 }37 } catch (ParserException e) {38 addErrorAttachment (events, e, sourceEvent.uri);39 }40 return events;41 }42 private void addErrorAttachment (List<IEvent> events, ParserException e, String uri)...

Full Screen

Full Screen

FeatureFileRepository.cs

Source:FeatureFileRepository.cs Github

copy

Full Screen

...17 : throw new ArgumentNullException(nameof(featureFileSearchPattern));18 }19 public FeatureFile GetByFilePath(string filePath)20 {21 var gherkinDocument = ParseGherkinDocument(filePath);22 return new FeatureFile(gherkinDocument);23 }24 private static GherkinDocument ParseGherkinDocument(string filePath)25 {26 var parser = new Parser();27 using (var gherkinFile = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))28 {29 using (var gherkinReader = new StreamReader(gherkinFile))30 {31 var gherkinDocument = parser.Parse(gherkinReader);32 return gherkinDocument;33 }34 }35 }3637 public List<string> GetFeatureFilePaths()38 { ...

Full Screen

Full Screen

FeatureFile.cs

Source:FeatureFile.cs Github

copy

Full Screen

...3namespace Xunit.Gherkin.Quick4{5 internal sealed class FeatureFile6 {7 public GherkinDocument GherkinDocument { get; }8 public FeatureFile(GherkinDocument gherkinDocument)9 {10 GherkinDocument = gherkinDocument ?? throw new System.ArgumentNullException(nameof(gherkinDocument));11 }12 public global::Gherkin.Ast.Scenario GetScenario(string scenarioName)13 {14 return GherkinDocument.Feature.Children.FirstOrDefault(s => s.Name == scenarioName) as global::Gherkin.Ast.Scenario;15 }16 public global::Gherkin.Ast.Background GetBackground()17 {18 return GherkinDocument.Feature.Children.OfType<global::Gherkin.Ast.Background>().SingleOrDefault();19 }20 internal ScenarioOutline GetScenarioOutline(string scenarioOutlineName)21 {22 return GherkinDocument.Feature.Children.FirstOrDefault(s => s.Name == scenarioOutlineName) as global::Gherkin.Ast.ScenarioOutline;23 }24 }25}...

Full Screen

Full Screen

Parser.Extensions.cs

Source:Parser.Extensions.cs Github

copy

Full Screen

1using System.IO;2using Gherkin.Ast;3namespace Gherkin4{5 public class Parser : Parser<GherkinDocument>6 {7 public Parser()8 {9 }10 public Parser(IAstBuilder<GherkinDocument> astBuilder)11 : base (astBuilder)12 {13 }14 public GherkinDocument Parse(TextReader reader)15 {16 return Parse(new TokenScanner(reader));17 }18 public GherkinDocument Parse(string sourceFile)19 {20 using (var reader = new StreamReader(sourceFile))21 {22 return Parse(new TokenScanner(reader));23 }24 }25 }26}...

Full Screen

Full Screen

GherkinDocument

Using AI Code Generation

copy

Full Screen

1using Gherkin.Ast;2using System;3using System.Collections.Generic;4using System.Linq;5using System.Text;6using System.Threading.Tasks;7{8 {9 static void Main(string[] args)10 {11Then it should work";12 GherkinDocument gherkinDocument = new GherkinDocument(feature);13 Console.WriteLine(gherkinDocument.ToString());14 Console.ReadLine();15 }16 }17}18using Gherkin;19using Gherkin.Ast;20using System;21using System.Collections.Generic;22using System.Linq;23using System.Text;24using System.Threading.Tasks;25{26 {27 static void Main(string[] args)28 {29Then it should work";30 Parser parser = new Parser();31 GherkinDocument gherkinDocument = parser.Parse(feature);32 Console.WriteLine(gherkinDocument.ToString());33 Console.ReadLine();34 }35 }36}37using Gherkin;38using Gherkin.Ast;39using System;40using System.Collections.Generic;41using System.Linq;42using System.Text;43using System.Threading.Tasks;44{45 {46 static void Main(string[] args)47 {48Then it should work";49 Parser parser = new Parser();50 GherkinDocument gherkinDocument = parser.Parse(feature);51 Console.WriteLine(gherkinDocument.ToString());52 Console.ReadLine();53 }54 }55}56using Gherkin;57using Gherkin.Ast;58using System;59using System.Collections.Generic;60using System.Linq;61using System.Text;62using System.Threading.Tasks;63{64 {65 static void Main(string[] args)

Full Screen

Full Screen

GherkinDocument

Using AI Code Generation

copy

Full Screen

1using System;2using System.Collections.Generic;3using System.Linq;4using System.Text;5using System.Threading.Tasks;6using Gherkin.Ast;7using Gherkin.Parser;8using Gherkin.TokenMatcher;9using Gherkin;10using System.IO;11{12 {13 static void Main(string[] args)14 {15 string path = @"C:\Users\moham\Desktop\Gherkin\Gherkin\Feature1.feature";16 GherkinParser parser = new GherkinParser();17 GherkinDocument gherkinDocument = parser.Parse(File.ReadAllText(path));18 string feature = gherkinDocument.Feature.Description;19 List<ScenarioDefinition> scenarios = gherkinDocument.Feature.Children;20 List<Step> steps = scenarios[0].Steps;21 Console.WriteLine(feature);22 foreach (Step step in steps)23 {24 Console.WriteLine(step.Text);25 }26 Console.ReadLine();27 }28 }29}30using System;31using System.Collections.Generic;32using System.Linq;33using System.Text;34using System.Threading.Tasks;35using Gherkin.Ast;36using Gherkin.Parser;37using Gherkin.TokenMatcher;38using Gherkin;39using System.IO;40{41 {42 static void Main(string[] args)43 {44 string path = @"C:\Users\moham\Desktop\Gherkin\Gherkin\Feature1.feature";

Full Screen

Full Screen

GherkinDocument

Using AI Code Generation

copy

Full Screen

1using System;2using System.IO;3using System.Text;4using Gherkin.Ast;5using Gherkin.Parser;6{7 {8 static void Main(string[] args)9 {10 GherkinParser parser = new GherkinParser();11 GherkinDialectProvider dialectProvider = new GherkinDialectProvider("en");12 GherkinDialect dialect = dialectProvider.GetDialect("en", null);13 GherkinTokenMatcher matcher = new GherkinTokenMatcher(dialect);14 GherkinTokenScanner scanner = new GherkinTokenScanner(dialect);15 GherkinDocumentBuilder builder = new GherkinDocumentBuilder(scanner, matcher);16 string feature = File.ReadAllText("C:\\Users\\Public\\Documents\\Feature1.feature");17 GherkinDocument gherkinDoc = parser.Parse(feature, builder);18 Feature featureNode = gherkinDoc.Feature;19 var children = featureNode.Children;20 foreach (var child in children)21 {22 if (child is Background)23 {24 var steps = ((Background)child).Steps;25 foreach (var step in steps)26 {27 string stepText = step.Text;28 var argument = step.Argument;29 if (argument is DataTable)30 {31 var rows = ((DataTable)argument).Rows;32 foreach (var row in rows)

Full Screen

Full Screen

GherkinDocument

Using AI Code Generation

copy

Full Screen

1using System;2using Gherkin.Ast;3using System.Collections.Generic;4using Gherkin;5{6 {7 static void Main(string[] args)8 {9 GherkinDocument gherkinDocument = new GherkinDocument();10 GherkinDocumentBuilder gherkinDocumentBuilder = new GherkinDocumentBuilder();11 GherkinParser gherkinParser = new GherkinParser();12 GherkinDialectProvider gherkinDialectProvider = new GherkinDialectProvider();13 string featureFileContent = System.IO.File.ReadAllText(@"C:\Users\Public\TestFolder\test.feature");14 gherkinParser.Parse(featureFileContent, gherkinDocumentBuilder, gherkinDialectProvider.GetDialect("en", null));15 gherkinDocument = gherkinDocumentBuilder.GetGherkinDocument();16 Feature feature = gherkinDocument.Feature;17 string featureDescription = feature.Description;18 List<Tag> featureTags = feature.Tags;19 string featureKeyword = feature.Keyword;20 string featureName = feature.Name;21 Location featureLocation = feature.Location;22 List<IGherkinDocumentFeatureChild> featureChildren = feature.Children;23 Background background = featureChildren[0] as Background;24 string backgroundDescription = background.Description;25 string backgroundKeyword = background.Keyword;26 string backgroundName = background.Name;27 Location backgroundLocation = background.Location;28 List<Step> backgroundSteps = background.Steps;29 Scenario scenario = featureChildren[1] as Scenario;

Full Screen

Full Screen

GherkinDocument

Using AI Code Generation

copy

Full Screen

1Gherkin.Ast.GherkinDocument gherkinDocument = Gherkin.Ast.GherkinDocument.Parse("Feature: Hello World2");3Gherkin.Ast.Feature feature = gherkinDocument.Feature;4Console.WriteLine(feature.Name);5Gherkin.Ast.GherkinDocument gherkinDocument = Gherkin.Ast.GherkinDocument.Parse("Feature: Hello World6");7Gherkin.Ast.Feature feature = gherkinDocument.Feature;8Gherkin.Ast.Scenario scenario = feature.Children[0] as Gherkin.Ast.Scenario;9Console.WriteLine(scenario.Name);10Gherkin.Ast.GherkinDocument gherkinDocument = Gherkin.Ast.GherkinDocument.Parse("Feature: Hello World11");12Gherkin.Ast.Feature feature = gherkinDocument.Feature;13Gherkin.Ast.Scenario scenario = feature.Children[0] as Gherkin.Ast.Scenario;14Gherkin.Ast.Step step = scenario.Steps[0];15Console.WriteLine(step.Keyword);16Gherkin.Ast.GherkinDocument gherkinDocument = Gherkin.Ast.GherkinDocument.Parse("Feature: Hello World17");18Gherkin.Ast.Feature feature = gherkinDocument.Feature;19Gherkin.Ast.Scenario scenario = feature.Children[0] as Gherkin.Ast.Scenario;20Gherkin.Ast.Step step = scenario.Steps[0];21Console.WriteLine(step.Text);22Gherkin.Ast.GherkinDocument gherkinDocument = Gherkin.Ast.GherkinDocument.Parse("Feature: Hello World23");24Gherkin.Ast.Feature feature = gherkinDocument.Feature;

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Gherkin-dotnet automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in GherkinDocument

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful