Skip to content

Commit

Permalink
Handling asterisks in feature files as And-Steps.
Browse files Browse the repository at this point in the history
  • Loading branch information
jbandi committed Jul 3, 2010
1 parent 32b94b4 commit 4b8c0c5
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Parser/GherkinBuilder/StepBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ internal class StepBuilder : ITableProcessor

public StepBuilder(string keyword, string text, FilePosition position, I18n i18n)
{
if (i18n.keywords("given").contains(keyword)) step = new Given();
if (i18n.keywords("and").contains(keyword)) step = new And();
else if (i18n.keywords("given").contains(keyword)) step = new Given();
else if (i18n.keywords("when").contains(keyword)) step = new When();
else if (i18n.keywords("then").contains(keyword)) step = new Then();
else if (i18n.keywords("and").contains(keyword)) step = new And();
else if (i18n.keywords("but").contains(keyword)) step = new But();
else throw new ArgumentOutOfRangeException(string.Format("Parameter 'keyword' has value that can not be translated! Value:'{0}'", keyword));

Expand Down
7 changes: 7 additions & 0 deletions Tests/ParserTests/SuccessfulGenerationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ public void CanGenerateSimpleFeature()
CanGenerateFromFile(Path.Combine(folder, "simple.feature"));
}

[Test]
public void CanGenerateAsterisksFeature()
{
var folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
CanGenerateFromFile(Path.Combine(folder, "asterisks.feature"));
}

[Test]
public void CanGenerateCommentsFeature()
{
Expand Down
7 changes: 7 additions & 0 deletions Tests/ParserTests/SuccessfulParsingTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ public void CanParseSimpleFeature()
{
var folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
CanParseFile(Path.Combine(folder, "simple.feature"));
}

[Test]
public void CanGenerateAsterisksFeature()
{
var folder = Path.GetFullPath(Path.Combine(TestFileHelper.GetProjectLocation(), "TestFiles"));
CanParseFile(Path.Combine(folder, "asterisks.feature"));
}

[Test]
Expand Down
8 changes: 8 additions & 0 deletions Tests/ParserTests/TestFiles/asterisks.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Feature: a very simple feature

Scenario: a simple scenario
Given some precondition
* some precondition2
When I do something
* I do something2
Then something happens
34 changes: 34 additions & 0 deletions Tests/ParserTests/TestFiles/asterisks.feature.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<Feature xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Language>en-US</Language>
<Scenarios>
<Scenario>
<Title>a simple scenario</Title>
<FilePosition line="3" column="1" />
<Steps>
<ScenarioStep xsi:type="Given">
<Text>some precondition</Text>
<FilePosition line="4" column="1" />
</ScenarioStep>
<ScenarioStep xsi:type="And">
<Text>some precondition2</Text>
<FilePosition line="5" column="1" />
</ScenarioStep>
<ScenarioStep xsi:type="When">
<Text>I do something</Text>
<FilePosition line="6" column="1" />
</ScenarioStep>
<ScenarioStep xsi:type="And">
<Text>I do something2</Text>
<FilePosition line="7" column="1" />
</ScenarioStep>
<ScenarioStep xsi:type="Then">
<Text>something happens</Text>
<FilePosition line="8" column="1" />
</ScenarioStep>
</Steps>
</Scenario>
</Scenarios>
<Title>a very simple feature</Title>
<Description />
</Feature>

0 comments on commit 4b8c0c5

Please sign in to comment.