public void ThenCanParseMostBasicFeatureSuccessfully() { string featureText = @"# language: sv # ignorera denna kommentar Egenskap: Test egenskap Som svensk användare Vill jag skriva mina krav på svenska Så att beställaren kan förstå dem Scenario: Ett scenario Givet en egenskap När den körs Så skall jag se att det inträffat"; var configuration = new Configuration { Language = "sv" }; var parser = new FeatureParser(FileSystem); Feature feature = parser.Parse(new StringReader(featureText)); Check.That(feature).IsNotNull(); Check.That(feature.Name).IsEqualTo("Test egenskap"); Check.That(feature.Description.ComparisonNormalize()).IsEqualTo(@" Som svensk användare Vill jag skriva mina krav på svenska Så att beställaren kan förstå dem".ComparisonNormalize()); Check.That(feature.FeatureElements.Count).IsEqualTo(1); Check.That(feature.Tags.Count).IsEqualTo(0); IFeatureElement scenario = feature.FeatureElements.First(); Check.That(scenario.Name).IsEqualTo("Ett scenario"); Check.That(scenario.Description).IsEqualTo(string.Empty); Check.That(scenario.Steps.Count).IsEqualTo(3); Check.That(scenario.Tags.Count).IsEqualTo(0); Step givenStep = scenario.Steps[0]; Check.That(givenStep.Keyword).IsEqualTo(Keyword.Given); Check.That(givenStep.Name).IsEqualTo("en egenskap"); Check.That(givenStep.DocStringArgument).IsNull(); Check.That(givenStep.TableArgument).IsNull(); Step whenStep = scenario.Steps[1]; Check.That(whenStep.Keyword).IsEqualTo(Keyword.When); Check.That(whenStep.Name).IsEqualTo("den körs"); Check.That(whenStep.DocStringArgument).IsNull(); Check.That(whenStep.TableArgument).IsNull(); Step thenStep = scenario.Steps[2]; Check.That(thenStep.Keyword).IsEqualTo(Keyword.Then); Check.That(thenStep.Name).IsEqualTo("skall jag se att det inträffat"); Check.That(thenStep.DocStringArgument).IsNull(); Check.That(thenStep.TableArgument).IsNull(); }
public void ThenCanParseMostBasicFeatureSuccessfully() { string featureText = @"# ignorera denna kommentar Egenskap: Test egenskap Som svensk användare Vill jag skriva mina krav på svenska Så att beställaren kan förstå dem Scenario: Ett scenario Givet en egenskap När den körs Så skall jag se att det inträffat"; var configuration = new Configuration { Language = "sv" }; var parser = new FeatureParser(new LanguageServices(configuration), FileSystem); Feature feature = parser.Parse(new StringReader(featureText)); feature.ShouldNotBeNull(); feature.Name.ShouldEqual("Test egenskap"); feature.Description.ShouldEqual(@" Som svensk användare Vill jag skriva mina krav på svenska Så att beställaren kan förstå dem"); feature.FeatureElements.Count.ShouldEqual(1); feature.Tags.Count.ShouldEqual(0); IFeatureElement scenario = feature.FeatureElements.First(); scenario.Name.ShouldEqual("Ett scenario"); scenario.Description.ShouldEqual(string.Empty); scenario.Steps.Count.ShouldEqual(3); scenario.Tags.Count.ShouldEqual(0); Step givenStep = scenario.Steps[0]; givenStep.Keyword.ShouldEqual(Keyword.Given); givenStep.Name.ShouldEqual("en egenskap"); givenStep.DocStringArgument.ShouldBeNull(); givenStep.TableArgument.ShouldBeNull(); Step whenStep = scenario.Steps[1]; Assert.AreEqual(Keyword.When, whenStep.Keyword); Assert.AreEqual("den körs", whenStep.Name); whenStep.DocStringArgument.ShouldBeNull(); whenStep.TableArgument.ShouldBeNull(); Step thenStep = scenario.Steps[2]; thenStep.Keyword.ShouldEqual(Keyword.Then); thenStep.Name.ShouldEqual("skall jag se att det inträffat"); thenStep.DocStringArgument.ShouldBeNull(); thenStep.TableArgument.ShouldBeNull(); }
private static string DetermineStatus(IFeatureElement fe) { var testResult = fe.Result; if (testResult == TestResult.NotProvided) { testResult = TestResult.Inconclusive; } return(testResult.ToString().ToLowerInvariant()); }
public void ThenCanParseMostBasicFeatureSuccessfully() { string featureText = @"# ignore this comment Feature: Test In order to do something As a user I want to run this scenario Scenario: A scenario Given some feature When it runs Then I should see that this thing happens"; var parser = Container.Resolve <FeatureParser>(); Feature feature = parser.Parse(new StringReader(featureText)); Assert.AreNotEqual(null, feature); Assert.AreEqual("Test", feature.Name); Assert.AreEqual(@" In order to do something As a user I want to run this scenario", feature.Description); Assert.AreEqual(1, feature.FeatureElements.Count); Assert.AreEqual(0, feature.Tags.Count); IFeatureElement scenario = feature.FeatureElements.First(); Assert.AreEqual("A scenario", scenario.Name); Assert.AreEqual(string.Empty, scenario.Description); Assert.AreEqual(3, scenario.Steps.Count); Assert.AreEqual(0, scenario.Tags.Count); Step givenStep = scenario.Steps[0]; Assert.AreEqual(Keyword.Given, givenStep.Keyword); Assert.AreEqual("some feature", givenStep.Name); Assert.AreEqual(null, givenStep.DocStringArgument); Assert.AreEqual(null, givenStep.TableArgument); Step whenStep = scenario.Steps[1]; Assert.AreEqual(Keyword.When, whenStep.Keyword); Assert.AreEqual("it runs", whenStep.Name); Assert.AreEqual(null, whenStep.DocStringArgument); Assert.AreEqual(null, whenStep.TableArgument); Step thenStep = scenario.Steps[2]; Assert.AreEqual(Keyword.Then, thenStep.Keyword); Assert.AreEqual("I should see that this thing happens", thenStep.Name); Assert.AreEqual(null, thenStep.DocStringArgument); Assert.AreEqual(null, thenStep.TableArgument); }
public void ThenCanParseMostBasicFeatureSuccessfully() { string featureText = @"# ignore this comment Feature: Test In order to do something As a user I want to run this scenario Scenario: A scenario Given some feature When it runs Then I should see that this thing happens"; var parser = Container.Resolve <FeatureParser>(); Feature feature = parser.Parse(new StringReader(featureText)); Check.That(feature).IsNotNull(); Check.That(feature.Name).IsEqualTo("Test"); Check.That(feature.Description.ComparisonNormalize()).IsEqualTo(@" In order to do something As a user I want to run this scenario".ComparisonNormalize()); Check.That(feature.FeatureElements.Count).IsEqualTo(1); Check.That(feature.Tags).IsEmpty(); IFeatureElement scenario = feature.FeatureElements.First(); Check.That(scenario.Name).IsEqualTo("A scenario"); Check.That(scenario.Description).IsEqualTo(string.Empty); Check.That(scenario.Steps.Count).IsEqualTo(3); Check.That(scenario.Tags).IsEmpty(); Step givenStep = scenario.Steps[0]; Check.That(givenStep.Keyword).IsEqualTo(Keyword.Given); Check.That(givenStep.Name).IsEqualTo("some feature"); Check.That(givenStep.DocStringArgument).IsNull(); Check.That(givenStep.TableArgument).IsNull(); Step whenStep = scenario.Steps[1]; Check.That(whenStep.Keyword).IsEqualTo(Keyword.When); Check.That(whenStep.Name).IsEqualTo("it runs"); Check.That(whenStep.DocStringArgument).IsNull(); Check.That(whenStep.TableArgument).IsNull(); Step thenStep = scenario.Steps[2]; Check.That(thenStep.Keyword).IsEqualTo(Keyword.Then); Check.That(thenStep.Name).IsEqualTo("I should see that this thing happens"); Check.That(thenStep.DocStringArgument).IsNull(); Check.That(thenStep.TableArgument).IsNull(); }
private IJsonFeatureElement MapFeatureElement(IFeatureElement arg) { var scenario = arg as Scenario; if (scenario != null) { return(this.scenarioMapper.Map(scenario)); } var scenarioOutline = arg as ScenarioOutline; if (scenarioOutline != null) { return(this.scenarioOutlineMapper.Map(scenarioOutline)); } throw new ArgumentException("Only arguments of type Scenario and ScenarioOutline are supported."); }
private IJsonFeatureElement MapFeatureElement(IFeatureElement arg) { var scenario = arg as Scenario; if (scenario != null) { return this.scenarioMapper.Map(scenario); } var scenarioOutline = arg as ScenarioOutline; if (scenarioOutline != null) { return this.scenarioOutlineMapper.Map(scenarioOutline); } throw new ArgumentException("Only arguments of type Scenario and ScenarioOutline are supported."); }
public void Then_can_parse_scenario_with_comments_successfully() { string featureText = @"# ignore this comment Feature: Test In order to do something As a user I want to run this scenario Scenario: A scenario # A single line comment Given some feature # A multiline comment - first line # Second line When it runs Then I should see that this thing happens # A last comment after the scenario"; var parser = Container.Resolve <FeatureParser>(); Feature feature = parser.Parse(new StringReader(featureText)); IFeatureElement scenario = feature.FeatureElements.First(); Step stepGiven = scenario.Steps[0]; Check.That(stepGiven.Comments.Count).IsEqualTo(1); Check.That(stepGiven.Comments[0].Text).IsEqualTo("# A single line comment"); Step stepWhen = scenario.Steps[1]; Check.That(stepWhen.Comments.Count).IsEqualTo(2); Check.That(stepWhen.Comments[0].Text).IsEqualTo("# A multiline comment - first line"); Check.That(stepWhen.Comments[1].Text).IsEqualTo("# Second line"); Step stepThen = scenario.Steps[2]; Check.That(stepThen.Comments.Count).IsEqualTo(1); Check.That(stepThen.Comments.Count(o => o.Type == CommentType.StepComment)).IsEqualTo(0); Check.That(stepThen.Comments.Count(o => o.Type == CommentType.AfterLastStepComment)).IsEqualTo(1); Check.That(stepThen.Comments[0].Text = "# A last comment after the scenario"); }
public void AddFeatureElement(IFeatureElement featureElement) { featureElement.Feature = this; this.FeatureElements.Add(featureElement); }
public void AddFeatureElement(IFeatureElement featureElement) { featureElement.Feature = this; this.FeatureElements.Add(featureElement); }
public void ThenCanParseFeatureWithMultipleScenariosSuccessfully() { string featureText = @"# ignore this comment Feature: Test In order to do something As a user I want to run this scenario Scenario: A scenario Given some feature When it runs Then I should see that this thing happens Scenario: Another scenario Given some other feature When it runs Then I should see that this other thing happens And something else"; var parser = Kernel.Get <FeatureParser>(); Feature feature = parser.Parse(new StringReader(featureText)); Assert.AreNotEqual(null, feature); Assert.AreEqual("Test", feature.Name); Assert.AreEqual(@" In order to do something As a user I want to run this scenario", feature.Description); Assert.AreEqual(2, feature.FeatureElements.Count); Assert.AreEqual(0, feature.Tags.Count); IFeatureElement scenario = feature.FeatureElements[0]; Assert.AreEqual("A scenario", scenario.Name); Assert.AreEqual(string.Empty, scenario.Description); Assert.AreEqual(3, scenario.Steps.Count); Assert.AreEqual(0, scenario.Tags.Count); Step givenStep = scenario.Steps[0]; Assert.AreEqual(Keyword.Given, givenStep.Keyword); Assert.AreEqual("some feature", givenStep.Name); Assert.AreEqual(null, givenStep.DocStringArgument); Assert.AreEqual(null, givenStep.TableArgument); Step whenStep = scenario.Steps[1]; Assert.AreEqual(Keyword.When, whenStep.Keyword); Assert.AreEqual("it runs", whenStep.Name); Assert.AreEqual(null, whenStep.DocStringArgument); Assert.AreEqual(null, whenStep.TableArgument); Step thenStep = scenario.Steps[2]; Assert.AreEqual(Keyword.Then, thenStep.Keyword); Assert.AreEqual("I should see that this thing happens", thenStep.Name); Assert.AreEqual(null, thenStep.DocStringArgument); Assert.AreEqual(null, thenStep.TableArgument); IFeatureElement scenario2 = feature.FeatureElements[1]; Assert.AreEqual("Another scenario", scenario2.Name); Assert.AreEqual(string.Empty, scenario2.Description); Assert.AreEqual(4, scenario2.Steps.Count); Assert.AreEqual(0, scenario2.Tags.Count); Step givenStep2 = scenario2.Steps[0]; Assert.AreEqual(Keyword.Given, givenStep2.Keyword); Assert.AreEqual("some other feature", givenStep2.Name); Assert.AreEqual(null, givenStep2.DocStringArgument); Assert.AreEqual(null, givenStep2.TableArgument); Step whenStep2 = scenario2.Steps[1]; Assert.AreEqual(Keyword.When, whenStep2.Keyword); Assert.AreEqual("it runs", whenStep2.Name); Assert.AreEqual(null, whenStep2.DocStringArgument); Assert.AreEqual(null, whenStep2.TableArgument); Step thenStep2 = scenario2.Steps[2]; Assert.AreEqual(Keyword.Then, thenStep2.Keyword); Assert.AreEqual("I should see that this other thing happens", thenStep2.Name); Assert.AreEqual(null, thenStep2.DocStringArgument); Assert.AreEqual(null, thenStep2.TableArgument); Step thenStep3 = scenario2.Steps[3]; Assert.AreEqual(Keyword.And, thenStep3.Keyword); Assert.AreEqual("something else", thenStep3.Name); Assert.AreEqual(null, thenStep3.DocStringArgument); Assert.AreEqual(null, thenStep3.TableArgument); }
public void ThenCanParseFeatureWithMultipleScenariosSuccessfully() { string featureText = @"# ignore this comment Feature: Test In order to do something As a user I want to run this scenario Scenario: A scenario Given some feature When it runs Then I should see that this thing happens Scenario: Another scenario Given some other feature When it runs Then I should see that this other thing happens And something else"; var parser = Container.Resolve <FeatureParser>(); Feature feature = parser.Parse(new StringReader(featureText)); Check.That(feature).IsNotNull(); Check.That(feature.Name).IsEqualTo("Test"); Check.That(feature.Description).IsEqualTo(@" In order to do something As a user I want to run this scenario"); Check.That(feature.FeatureElements.Count).IsEqualTo(2); Check.That(feature.Tags).IsEmpty(); IFeatureElement scenario = feature.FeatureElements[0]; Check.That(scenario.Name).IsEqualTo("A scenario"); Check.That(scenario.Description).IsEqualTo(""); Check.That(scenario.Steps.Count).IsEqualTo(3); Check.That(scenario.Tags).IsEmpty(); Step givenStep = scenario.Steps[0]; Check.That(givenStep.Keyword).IsEqualTo(Keyword.Given); Check.That(givenStep.Name).IsEqualTo("some feature"); Check.That(givenStep.DocStringArgument).IsNull(); Check.That(givenStep.TableArgument).IsNull(); Step whenStep = scenario.Steps[1]; Check.That(whenStep.Keyword).IsEqualTo(Keyword.When); Check.That(whenStep.Name).IsEqualTo("it runs"); Check.That(whenStep.DocStringArgument).IsNull(); Check.That(whenStep.TableArgument).IsNull(); Step thenStep = scenario.Steps[2]; Check.That(thenStep.Keyword).IsEqualTo(Keyword.Then); Check.That(thenStep.Name).IsEqualTo("I should see that this thing happens"); Check.That(thenStep.DocStringArgument).IsNull(); Check.That(thenStep.TableArgument).IsNull(); IFeatureElement scenario2 = feature.FeatureElements[1]; Check.That(scenario2.Name).IsEqualTo("Another scenario"); Check.That(scenario2.Description).IsEqualTo(string.Empty); Check.That(scenario2.Steps.Count).IsEqualTo(4); Check.That(scenario2.Tags).IsEmpty(); Step givenStep2 = scenario2.Steps[0]; Check.That(givenStep2.Keyword).IsEqualTo(Keyword.Given); Check.That(givenStep2.Name).IsEqualTo("some other feature"); Check.That(givenStep2.DocStringArgument).IsNull(); Check.That(givenStep2.TableArgument).IsNull(); Step whenStep2 = scenario2.Steps[1]; Check.That(whenStep2.Keyword).IsEqualTo(Keyword.When); Check.That(whenStep2.Name).IsEqualTo("it runs"); Check.That(whenStep2.DocStringArgument).IsNull(); Check.That(whenStep2.TableArgument).IsNull(); Step thenStep2 = scenario2.Steps[2]; Check.That(thenStep2.Keyword).IsEqualTo(Keyword.Then); Check.That(thenStep2.Name).IsEqualTo("I should see that this other thing happens"); Check.That(thenStep2.DocStringArgument).IsNull(); Check.That(thenStep2.TableArgument).IsNull(); Step thenStep3 = scenario2.Steps[3]; Check.That(thenStep3.Keyword).IsEqualTo(Keyword.And); Check.That(thenStep3.Name).IsEqualTo("something else"); Check.That(thenStep3.DocStringArgument).IsNull(); Check.That(thenStep3.TableArgument).IsNull(); }