From 4b8c0c510019dc446823fcb777d52a320d0edc28 Mon Sep 17 00:00:00 2001 From: jbandi Date: Sat, 3 Jul 2010 17:23:54 +0200 Subject: [PATCH] Handling asterisks in feature files as And-Steps. --- Parser/GherkinBuilder/StepBuilder.cs | 4 +-- Tests/ParserTests/SuccessfulGenerationTest.cs | 7 ++++ Tests/ParserTests/SuccessfulParsingTest.cs | 7 ++++ Tests/ParserTests/TestFiles/asterisks.feature | 8 +++++ .../TestFiles/asterisks.feature.xml | 34 +++++++++++++++++++ 5 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 Tests/ParserTests/TestFiles/asterisks.feature create mode 100644 Tests/ParserTests/TestFiles/asterisks.feature.xml diff --git a/Parser/GherkinBuilder/StepBuilder.cs b/Parser/GherkinBuilder/StepBuilder.cs index 1b19c30c1..c0e2c8630 100644 --- a/Parser/GherkinBuilder/StepBuilder.cs +++ b/Parser/GherkinBuilder/StepBuilder.cs @@ -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)); diff --git a/Tests/ParserTests/SuccessfulGenerationTest.cs b/Tests/ParserTests/SuccessfulGenerationTest.cs index 59d4db070..ca8b30e26 100644 --- a/Tests/ParserTests/SuccessfulGenerationTest.cs +++ b/Tests/ParserTests/SuccessfulGenerationTest.cs @@ -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() { diff --git a/Tests/ParserTests/SuccessfulParsingTest.cs b/Tests/ParserTests/SuccessfulParsingTest.cs index 402a04bbe..c592b4b87 100644 --- a/Tests/ParserTests/SuccessfulParsingTest.cs +++ b/Tests/ParserTests/SuccessfulParsingTest.cs @@ -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] diff --git a/Tests/ParserTests/TestFiles/asterisks.feature b/Tests/ParserTests/TestFiles/asterisks.feature new file mode 100644 index 000000000..2eee86624 --- /dev/null +++ b/Tests/ParserTests/TestFiles/asterisks.feature @@ -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 diff --git a/Tests/ParserTests/TestFiles/asterisks.feature.xml b/Tests/ParserTests/TestFiles/asterisks.feature.xml new file mode 100644 index 000000000..105b573d7 --- /dev/null +++ b/Tests/ParserTests/TestFiles/asterisks.feature.xml @@ -0,0 +1,34 @@ + + + en-US + + + a simple scenario + + + + some precondition + + + + some precondition2 + + + + I do something + + + + I do something2 + + + + something happens + + + + + + a very simple feature + + \ No newline at end of file