diff --git a/Tests/Reqnroll.Specs/Drivers/Parser/ParserDriver.cs b/Tests/Reqnroll.Specs/Drivers/Parser/ParserDriver.cs index 584826d40..3d16e4e66 100644 --- a/Tests/Reqnroll.Specs/Drivers/Parser/ParserDriver.cs +++ b/Tests/Reqnroll.Specs/Drivers/Parser/ParserDriver.cs @@ -115,6 +115,28 @@ public void AssertErrors(List expectedErrors) } } + public void AssertTableHasColumns(params string[] expectedColumns) + { + ParsedDocument.Should().NotBeNull("The parsing was not successful"); + + var scenario = ParsedDocument.ReqnrollFeature.Children.OfType().FirstOrDefault(); + scenario.Should().NotBeNull("No scenario found in the parsed document"); + + var step = scenario.Steps.FirstOrDefault(); + step.Should().NotBeNull("No step found in the scenario"); + + var table = step.Argument as Gherkin.Ast.DataTable; + table.Should().NotBeNull("No table argument found in the step"); + + var headerRow = table.Rows.FirstOrDefault(); + headerRow.Should().NotBeNull("Table has no rows"); + + var actualColumns = headerRow.Cells.Select(c => c.Value).ToList(); + + actualColumns.Should().BeEquivalentTo(expectedColumns, + "the parsed table should have the expected columns"); + } + public void SaveSerializedFeatureTo(string fileName) { ParsedDocument.Should().NotBeNull("The parsing was not successful"); diff --git a/Tests/Reqnroll.Specs/Features/Parser/ParsingErrors.feature b/Tests/Reqnroll.Specs/Features/Parser/ParsingErrors.feature index de1fb17b1..a0f15db5f 100644 --- a/Tests/Reqnroll.Specs/Features/Parser/ParsingErrors.feature +++ b/Tests/Reqnroll.Specs/Features/Parser/ParsingErrors.feature @@ -159,3 +159,23 @@ Scenario: Duplicated background | line | error | | 6 | got 'Background:' | +Scenario: Table without trailing delimiter on any row + # This test demonstrates issue #964: when all rows are missing the trailing pipe delimiter, + # the parser silently ignores the last column instead of reporting an error. + # Expected behavior: should report an error or warning about missing trailing delimiter + # Actual behavior: no error is reported, and the last column is silently ignored + Given there is a Gherkin file as + """ + Feature: Table without trailing delimiter + + Scenario: Table without trailing delimiter + Given a table + | EffectiveDate | InterestRate + | 1999-01-01 | 10.00 + """ + When the file is parsed + Then no parsing error is reported + And the parsed table has only the following columns + | column | + | EffectiveDate | + diff --git a/Tests/Reqnroll.Specs/StepDefinitions/GherkinParserSteps.cs b/Tests/Reqnroll.Specs/StepDefinitions/GherkinParserSteps.cs index c14fad67c..d08e6c588 100644 --- a/Tests/Reqnroll.Specs/StepDefinitions/GherkinParserSteps.cs +++ b/Tests/Reqnroll.Specs/StepDefinitions/GherkinParserSteps.cs @@ -44,5 +44,12 @@ public void ThenTheTheFollowingErrorsAreProvided(List expectedErr { _parserDriver.AssertErrors(expectedErrors); } + + [Then(@"the parsed table has only the following columns")] + public void ThenTheParsedTableHasOnlyTheFollowingColumns(Table table) + { + var expectedColumns = table.Rows.Select(r => r["column"]).ToArray(); + _parserDriver.AssertTableHasColumns(expectedColumns); + } } }