Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Gherkin to v28 #205

Merged
merged 4 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Optimize creation of test-thread context using test framework independent resource pooling (#144)
* Support DateTimeOffset in value comparer (#180)
* Support 'Order' parameter for `StepArgumentTransformationAttribute` to prioritize execution (#185)
* Upgrade to Gherkin v28 from v19 (see [Gherkin changelog](https://github.com/cucumber/gherkin/blob/main/CHANGELOG.md)) (#205)

## Bug fixes:

Expand Down
2 changes: 1 addition & 1 deletion Reqnroll.Parser/Reqnroll.Parser.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Gherkin" Version="19.0.3" />
<PackageReference Include="Gherkin" Version="28.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions Reqnroll.Parser/ReqnrollGherkinParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ protected override Scenario CreateScenario(Tag[] tags, Location location, string

}

protected override Step CreateStep(Location location, string keyword, string text, StepArgument argument, AstNode node)
protected override Step CreateStep(Location location, string keyword, StepKeywordType keywordType, string text, StepArgument argument, AstNode node)
{
var token = node.GetToken(TokenType.StepLine);
var stepKeyword = GetStepKeyword(token.MatchedGherkinDialect, keyword);
scenarioBlock = stepKeyword.ToScenarioBlock() ?? scenarioBlock;

return new ReqnrollStep(location, keyword, text, argument, stepKeyword, scenarioBlock);
return new ReqnrollStep(location, keyword, keywordType, text, argument, stepKeyword, scenarioBlock);
}

private void ResetBlock()
Expand Down
8 changes: 2 additions & 6 deletions Reqnroll.Parser/ReqnrollStep.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Gherkin;
using Gherkin.Ast;

namespace Reqnroll.Parser
Expand All @@ -12,7 +8,7 @@ public class ReqnrollStep : Step
public ScenarioBlock ScenarioBlock { get; private set; }
public StepKeyword StepKeyword { get; private set; }

public ReqnrollStep(Location location, string keyword, string text, StepArgument argument, StepKeyword stepKeyword, ScenarioBlock scenarioBlock) : base(location, keyword, text, argument)
public ReqnrollStep(Location location, string keyword, StepKeywordType keywordType, string text, StepArgument argument, StepKeyword stepKeyword, ScenarioBlock scenarioBlock) : base(location, keyword, keywordType, text, argument)
{
StepKeyword = stepKeyword;
ScenarioBlock = scenarioBlock;
Expand Down
4 changes: 2 additions & 2 deletions Reqnroll/Reqnroll.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Gherkin" Version="19.0.3" />
<PackageReference Include="Cucumber.CucumberExpressions" Version="16.0.0" />
<PackageReference Include="Gherkin" Version="28.0.0" />
<PackageReference Include="Cucumber.CucumberExpressions" Version="17.1.0" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="6.0.0" />
<PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
<PackageReference Include="SpecFlow.Internal.Json" Version="1.0.8" />
Expand Down
4 changes: 2 additions & 2 deletions Reqnroll/Reqnroll.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
<copyright>$copyright$</copyright>
<dependencies>
<group targetFramework="netstandard2.0">
<dependency id="Gherkin" version="19.0.3"/>
<dependency id="Cucumber.CucumberExpressions" version="16.0.0"/>
<dependency id="Gherkin" version="28.0.0"/>
<dependency id="Cucumber.CucumberExpressions" version="17.1.0"/>

<dependency id="Microsoft.Extensions.DependencyModel" version="6.0.0" />
<dependency id="System.Runtime.Loader" version="4.3.0" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Gherkin;
using Gherkin.Ast;
using Moq;
using Reqnroll.ExternalData.ReqnrollPlugin.DataSources;
Expand Down Expand Up @@ -67,7 +68,7 @@ private ScenarioOutline CreateScenarioOutline(Examples[] examples)
"Scenario Outline",
"SO 1",
null,
new[] { new Step(null, "Given ", "the customer has <product>", null) },
new[] { new Step(null, "Given ", StepKeywordType.Context, "the customer has <product>", null) },
examples);
}

Expand All @@ -79,7 +80,7 @@ private Scenario CreateScenario()
"Scenario",
"S 1",
null,
new[] { new Step(null, "Given ", "the customer has stuff", null) },
new[] { new Step(null, "Given ", StepKeywordType.Context, "the customer has stuff", null) },
null);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Gherkin;
using Gherkin.Ast;
using Reqnroll.ExternalData.ReqnrollPlugin.Transformation;
using Reqnroll.Parser;
Expand Down Expand Up @@ -52,7 +53,7 @@ private ScenarioOutline CreateScenarioOutline()
"Scenario Outline",
$"SO {++_scenarioCounter}",
null,
new[] { new Step(null, "Given ", "the customer has <product>", null) },
new[] { new Step(null, "Given ", StepKeywordType.Context, "the customer has <product>", null) },
new[] { new Examples(new Tag[0], null, "Examples", "", "", new Gherkin.Ast.TableRow(null, new[] { new TableCell(null, "product") }), new Gherkin.Ast.TableRow[0]) });
}

Expand All @@ -64,7 +65,7 @@ private Scenario CreateScenario()
"Scenario",
$"S {++_scenarioCounter}",
null,
new[] { new Step(null, "Given ", "the customer has food", null) },
new[] { new Step(null, "Given ", StepKeywordType.Context, "the customer has food", null) },
null);
}

Expand Down
1 change: 0 additions & 1 deletion Tests/Reqnroll.Specs/Reqnroll.Specs.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@

<ItemGroup>
<PackageReference Include="MSBuild.AdditionalTasks" Version="*" />
<PackageReference Include="Gherkin" Version="19.0.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
<PackageReference Include="FluentAssertions" Version="6.7.0" />
<PackageReference Include="Moq" Version="4.17.2" />
Expand Down
31 changes: 16 additions & 15 deletions Tests/Reqnroll.Specs/StepDefinitions/TestFileSteps.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.IO;
using FluentAssertions;
using Reqnroll.Specs.Drivers;
using Reqnroll.Specs.Drivers.Parser;
using Reqnroll.Specs.Support;
using Reqnroll.TestProjectGenerator;
Expand All @@ -11,47 +10,49 @@ namespace Reqnroll.Specs.StepDefinitions
[Binding]
public class TestFileSteps
{
private readonly TestFileManager testFileManager;
private readonly ParserDriver parserDriver;
private readonly TestFileManager _testFileManager;
private readonly ParserDriver _parserDriver;
private readonly ProjectsDriver _projectsDriver;
private readonly ConfigurationDriver _configurationDriver;

public TestFileSteps(TestFileManager testFileManager, ParserDriver parserDriver, ProjectsDriver projectsDriver)
public TestFileSteps(TestFileManager testFileManager, ParserDriver parserDriver, ProjectsDriver projectsDriver, ConfigurationDriver configurationDriver)
{
this.testFileManager = testFileManager;
this.parserDriver = parserDriver;
_testFileManager = testFileManager;
_parserDriver = parserDriver;
_projectsDriver = projectsDriver;
_configurationDriver = configurationDriver;
}

[When(@"the test file '(.*)' is parsed")]
public void WhenTheTestFileIsParsed(string testFile)
{
string testFileContent = testFileManager.GetTestFileContent(testFile);
parserDriver.FileContent = testFileContent;
parserDriver.ParseFile();
string testFileContent = _testFileManager.GetTestFileContent(testFile);
_parserDriver.FileContent = testFileContent;
_parserDriver.ParseFile();
}

[When(@"the parsed result is saved to '(.*)'")]
public void WhenTheParsedResultIsSavedTo(string parsedFileName)
{
var assemblyFolder = AssemblyFolderHelper.GetAssemblyFolder();

assemblyFolder.Should().EndWith(@"\bin\Debug\net5.0", "parsed file saving can only be done from a development environment");
parserDriver.SaveSerializedFeatureTo(Path.Combine(assemblyFolder, @"..\..\..\TestFiles", parsedFileName));
_configurationDriver.PipelineMode.Should().BeFalse("parsed file saving can only be done from a development environment");
_parserDriver.SaveSerializedFeatureTo(Path.Combine(assemblyFolder, @"..\..\..\TestFiles", parsedFileName));
}

[Then(@"the parsed result is the same as '(.*)'")]
public void ThenTheParsedResultIsTheSameAs(string parsedFileName)
{
string expected = testFileManager.GetTestFileContent(parsedFileName);
parserDriver.AssertParsedFeatureEqualTo(expected);
string expected = _testFileManager.GetTestFileContent(parsedFileName);
_parserDriver.AssertParsedFeatureEqualTo(expected);
}

[Given(@"all test files are inluded in the project")]
public void GivenAllTestFilesAreInludedInTheProject()
{
foreach (var testFile in testFileManager.GetTestFeatureFiles())
foreach (var testFile in _testFileManager.GetTestFeatureFiles())
{
string testFileContent = testFileManager.GetTestFileContent(testFile);
string testFileContent = _testFileManager.GetTestFileContent(testFile);

_projectsDriver.AddFeatureFile(testFileContent);
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/Reqnroll.Specs/TestFiles/and.feature.json
Code-Grump marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"ReqnrollFeature":{"ScenarioDefinitions":[{"Tags":[],"Examples":[],"Location":{"Line":3,"Column":1},"Keyword":"Scenario","Name":"a simple scenario","Description":null,"Steps":[{"ScenarioBlock":1,"StepKeyword":1,"Location":{"Line":4,"Column":1},"Keyword":"Given ","Text":"some precondition","Argument":null},{"ScenarioBlock":1,"StepKeyword":4,"Location":{"Line":5,"Column":2},"Keyword":"And ","Text":"some precondition2","Argument":null},{"ScenarioBlock":2,"StepKeyword":2,"Location":{"Line":6,"Column":1},"Keyword":"When ","Text":"I do something","Argument":null},{"ScenarioBlock":2,"StepKeyword":4,"Location":{"Line":7,"Column":2},"Keyword":"And ","Text":"I do something2","Argument":null},{"ScenarioBlock":3,"StepKeyword":3,"Location":{"Line":8,"Column":1},"Keyword":"Then ","Text":"something happens","Argument":null}]}],"Background":null,"Tags":[],"Location":{"Line":1,"Column":1},"Language":"en-US","Keyword":"Feature","Name":"And","Description":null,"Children":[{"Tags":[],"Examples":[],"Location":{"Line":3,"Column":1},"Keyword":"Scenario","Name":"a simple scenario","Description":null,"Steps":[{"ScenarioBlock":1,"StepKeyword":1,"Location":{"Line":4,"Column":1},"Keyword":"Given ","Text":"some precondition","Argument":null},{"ScenarioBlock":1,"StepKeyword":4,"Location":{"Line":5,"Column":2},"Keyword":"And ","Text":"some precondition2","Argument":null},{"ScenarioBlock":2,"StepKeyword":2,"Location":{"Line":6,"Column":1},"Keyword":"When ","Text":"I do something","Argument":null},{"ScenarioBlock":2,"StepKeyword":4,"Location":{"Line":7,"Column":2},"Keyword":"And ","Text":"I do something2","Argument":null},{"ScenarioBlock":3,"StepKeyword":3,"Location":{"Line":8,"Column":1},"Keyword":"Then ","Text":"something happens","Argument":null}]}]},"DocumentLocation":{"SourceFilePath":"sample.feature","FeatureFolderPath":""},"SourceFilePath":"sample.feature","Feature":{"ScenarioDefinitions":[{"Tags":[],"Examples":[],"Location":{"Line":3,"Column":1},"Keyword":"Scenario","Name":"a simple scenario","Description":null,"Steps":[{"ScenarioBlock":1,"StepKeyword":1,"Location":{"Line":4,"Column":1},"Keyword":"Given ","Text":"some precondition","Argument":null},{"ScenarioBlock":1,"StepKeyword":4,"Location":{"Line":5,"Column":2},"Keyword":"And ","Text":"some precondition2","Argument":null},{"ScenarioBlock":2,"StepKeyword":2,"Location":{"Line":6,"Column":1},"Keyword":"When ","Text":"I do something","Argument":null},{"ScenarioBlock":2,"StepKeyword":4,"Location":{"Line":7,"Column":2},"Keyword":"And ","Text":"I do something2","Argument":null},{"ScenarioBlock":3,"StepKeyword":3,"Location":{"Line":8,"Column":1},"Keyword":"Then ","Text":"something happens","Argument":null}]}],"Background":null,"Tags":[],"Location":{"Line":1,"Column":1},"Language":"en-US","Keyword":"Feature","Name":"And","Description":null,"Children":[{"Tags":[],"Examples":[],"Location":{"Line":3,"Column":1},"Keyword":"Scenario","Name":"a simple scenario","Description":null,"Steps":[{"ScenarioBlock":1,"StepKeyword":1,"Location":{"Line":4,"Column":1},"Keyword":"Given ","Text":"some precondition","Argument":null},{"ScenarioBlock":1,"StepKeyword":4,"Location":{"Line":5,"Column":2},"Keyword":"And ","Text":"some precondition2","Argument":null},{"ScenarioBlock":2,"StepKeyword":2,"Location":{"Line":6,"Column":1},"Keyword":"When ","Text":"I do something","Argument":null},{"ScenarioBlock":2,"StepKeyword":4,"Location":{"Line":7,"Column":2},"Keyword":"And ","Text":"I do something2","Argument":null},{"ScenarioBlock":3,"StepKeyword":3,"Location":{"Line":8,"Column":1},"Keyword":"Then ","Text":"something happens","Argument":null}]}]},"Comments":[]}
{"ReqnrollFeature":{"ScenarioDefinitions":[{"Tags":[],"Examples":[],"Location":{"Line":3,"Column":1},"Keyword":"Scenario","Name":"a simple scenario","Description":null,"Steps":[{"ScenarioBlock":1,"StepKeyword":1,"Location":{"Line":4,"Column":1},"Keyword":"Given ","KeywordType":1,"Text":"some precondition","Argument":null},{"ScenarioBlock":1,"StepKeyword":4,"Location":{"Line":5,"Column":2},"Keyword":"And ","KeywordType":4,"Text":"some precondition2","Argument":null},{"ScenarioBlock":2,"StepKeyword":2,"Location":{"Line":6,"Column":1},"Keyword":"When ","KeywordType":2,"Text":"I do something","Argument":null},{"ScenarioBlock":2,"StepKeyword":4,"Location":{"Line":7,"Column":2},"Keyword":"And ","KeywordType":4,"Text":"I do something2","Argument":null},{"ScenarioBlock":3,"StepKeyword":3,"Location":{"Line":8,"Column":1},"Keyword":"Then ","KeywordType":3,"Text":"something happens","Argument":null}]}],"Background":null,"Tags":[],"Location":{"Line":1,"Column":1},"Language":"en-US","Keyword":"Feature","Name":"And","Description":null,"Children":[{"Tags":[],"Examples":[],"Location":{"Line":3,"Column":1},"Keyword":"Scenario","Name":"a simple scenario","Description":null,"Steps":[{"ScenarioBlock":1,"StepKeyword":1,"Location":{"Line":4,"Column":1},"Keyword":"Given ","KeywordType":1,"Text":"some precondition","Argument":null},{"ScenarioBlock":1,"StepKeyword":4,"Location":{"Line":5,"Column":2},"Keyword":"And ","KeywordType":4,"Text":"some precondition2","Argument":null},{"ScenarioBlock":2,"StepKeyword":2,"Location":{"Line":6,"Column":1},"Keyword":"When ","KeywordType":2,"Text":"I do something","Argument":null},{"ScenarioBlock":2,"StepKeyword":4,"Location":{"Line":7,"Column":2},"Keyword":"And ","KeywordType":4,"Text":"I do something2","Argument":null},{"ScenarioBlock":3,"StepKeyword":3,"Location":{"Line":8,"Column":1},"Keyword":"Then ","KeywordType":3,"Text":"something happens","Argument":null}]}]},"DocumentLocation":{"SourceFilePath":"sample.feature","FeatureFolderPath":""},"SourceFilePath":"sample.feature","Feature":{"ScenarioDefinitions":[{"Tags":[],"Examples":[],"Location":{"Line":3,"Column":1},"Keyword":"Scenario","Name":"a simple scenario","Description":null,"Steps":[{"ScenarioBlock":1,"StepKeyword":1,"Location":{"Line":4,"Column":1},"Keyword":"Given ","KeywordType":1,"Text":"some precondition","Argument":null},{"ScenarioBlock":1,"StepKeyword":4,"Location":{"Line":5,"Column":2},"Keyword":"And ","KeywordType":4,"Text":"some precondition2","Argument":null},{"ScenarioBlock":2,"StepKeyword":2,"Location":{"Line":6,"Column":1},"Keyword":"When ","KeywordType":2,"Text":"I do something","Argument":null},{"ScenarioBlock":2,"StepKeyword":4,"Location":{"Line":7,"Column":2},"Keyword":"And ","KeywordType":4,"Text":"I do something2","Argument":null},{"ScenarioBlock":3,"StepKeyword":3,"Location":{"Line":8,"Column":1},"Keyword":"Then ","KeywordType":3,"Text":"something happens","Argument":null}]}],"Background":null,"Tags":[],"Location":{"Line":1,"Column":1},"Language":"en-US","Keyword":"Feature","Name":"And","Description":null,"Children":[{"Tags":[],"Examples":[],"Location":{"Line":3,"Column":1},"Keyword":"Scenario","Name":"a simple scenario","Description":null,"Steps":[{"ScenarioBlock":1,"StepKeyword":1,"Location":{"Line":4,"Column":1},"Keyword":"Given ","KeywordType":1,"Text":"some precondition","Argument":null},{"ScenarioBlock":1,"StepKeyword":4,"Location":{"Line":5,"Column":2},"Keyword":"And ","KeywordType":4,"Text":"some precondition2","Argument":null},{"ScenarioBlock":2,"StepKeyword":2,"Location":{"Line":6,"Column":1},"Keyword":"When ","KeywordType":2,"Text":"I do something","Argument":null},{"ScenarioBlock":2,"StepKeyword":4,"Location":{"Line":7,"Column":2},"Keyword":"And ","KeywordType":4,"Text":"I do something2","Argument":null},{"ScenarioBlock":3,"StepKeyword":3,"Location":{"Line":8,"Column":1},"Keyword":"Then ","KeywordType":3,"Text":"something happens","Argument":null}]}]},"Comments":[]}
Loading