Skip to content

Commit

Permalink
Fix for #271 This PR modifies the Feature AST visitor to appropriatel…
Browse files Browse the repository at this point in the history
…y handle Rule Background steps. (#272)
  • Loading branch information
clrudolphi authored Oct 1, 2024
1 parent 03ecd34 commit 44078a1
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# [vNext]

* Fix: Rule Backgounds cause External Data Plugin to fail (#271) @clrudolphi
## Bug fixes:
* Modified VersionInfo class to force it to pull version information from the Reqnroll assembly
* Fix: Reqnroll.CustomPlugin NuGet package has a version mismatch for the System.CodeDom dependency (#244)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Feature: ExternalDataWithRuleBackgroundFromCSV

This feature demonstrates that Rule Background steps are handled appropriately when using the External Data Plugin.
This test validates a regression.

Rule: Steps in Background are properly executed
Background:
Given my favorite color is blue
@DataSource:products.csv
Scenario: The basket price is calculated correctly
The scenario will be treated as a scenario outline with the examples from the CSV file.
The CSV file contains multile fields, including product and price.
Given the price of <product> is €<price>
And the customer has put 1 pcs of <product> to the basket
When the basket price is calculated
Then the basket price should be €<price>
And the color given as my favorite was blue
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using NUnit.Framework;
using Reqnroll;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace XReqnroll.ExternalData.ReqnrollPlugin.IntegrationTest.StepDefinitions
{
[Binding]
internal class BackgroundStepsDefinitions
{
[Given("my favorite color is {word}")]
public void GivenMyFavoriteColorIs(string color)
{
_color = color;
}

private string _color;

[Then("the color given as my favorite was {word}")]
public void ThenTheColorGivenAsMyFavoriteWas(string color)
{
Assert.That(_color, Is.EqualTo(color));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ protected virtual void AcceptRule(Rule rule)
OnRuleVisiting(rule);
foreach (var ruleChild in rule.Children)
{
if (ruleChild is ScenarioOutline scenarioOutline) AcceptScenarioOutline(scenarioOutline);
if (ruleChild is Background background) AcceptBackground(background);
else if (ruleChild is ScenarioOutline scenarioOutline) AcceptScenarioOutline(scenarioOutline);
else if (ruleChild is Scenario scenario) AcceptScenario(scenario);
}
OnRuleVisited(rule);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private void OnScenarioVisitedInternal(Scenario scenario, Scenario transformedSc

protected override void OnBackgroundVisited(Background background)
{
_featureChildren.Add(background);
_currentChildren.Add(background);
}

protected override void OnRuleVisiting(Rule rule)
Expand Down

0 comments on commit 44078a1

Please sign in to comment.