@Test public void scenario1() throws IOException, ParameterMappingException { String resourceName = "/stories/incubation/complete_usecase_003_fragment_light.story"; specIt.withReporter(new ConsoleColoredReporter()); specIt.scanAnnotations(IncubationSteps.class); specIt.executeStoryContent(resourceAsString(resourceName)); }
@Test public void scan_multipleAliasesForKeyword() { String story = "Given a defined step" + NL + "With an other simple step"; specIt.withAlias(Keyword.Given, "With"); specIt.withAlias(Keyword.Given, "Given"); parser.scan(story, listener); List<RawElement> steps = listener.getSteps(); assertThat(steps, hasSize(2)); assertThat(steps.get(0), equalTo(rawPart(0, Keyword.Given, "Given a defined step\n", "Given"))); assertThat( steps.get(1), equalTo(rawPart(21, Keyword.Given, "With an other simple step", "With"))); }
@Test public void scan_multipleKeywords_andIsResolvedUsingPrevious() { String story = "Given a defined step" + NL + "With an other step" + NL + "And yet an other one"; specIt.withAlias(Keyword.Given, "Given"); specIt.withAlias(Keyword.Given, "With"); specIt.withAlias(Keyword.And, "And"); parser.scan(story, listener); List<RawElement> steps = listener.getSteps(); assertThat(steps, hasSize(3)); assertThat(steps.get(0), equalTo(rawPart(0, Keyword.Given, "Given a defined step\n", "Given"))); assertThat(steps.get(1), equalTo(rawPart(21, Keyword.Given, "With an other step\n", "With"))); assertThat(steps.get(2), equalTo(rawPart(40, Keyword.And, "And yet an other one", "And"))); }
@Test public void scan_fragmentAndRepeat() { String story = "Fragment: Add Value" + NL + "When I add 2 to x" + NL + NL + "Repeat [Add Value] 3 times"; specIt.withAlias(Keyword.Fragment, "Fragment:"); specIt.withAlias(Keyword.When, "When"); specIt.withAlias(Keyword.Repeat, "Repeat"); parser.scan(story, listener); List<RawElement> steps = listener.getSteps(); assertThat(steps, hasSize(3)); assertThat( steps.get(0), equalTo(rawPart(0, Keyword.Fragment, "Fragment: Add Value\n", "Fragment:"))); assertThat(steps.get(1), equalTo(rawPart(20, Keyword.When, "When I add 2 to x\n\n", "When"))); assertThat( steps.get(2), equalTo(rawPart(39, Keyword.Repeat, "Repeat [Add Value] 3 times", "Repeat"))); }
@Test public void scan_singleStep() { specIt.withAlias(Keyword.Given, "With"); parser.scan("With a simple step", listener); List<RawElement> steps = listener.getSteps(); assertThat(steps, hasSize(1)); assertThat(steps.get(0), equalTo(rawPart(0, Keyword.Given, "With a simple step", "With"))); }
@Test public void scan_withTrailingWhitechars_spaces() { specIt.withAlias(Keyword.Given, "With"); parser.scan("\n\n With a simple step", listener); List<RawElement> steps = listener.getSteps(); assertThat(steps, hasSize(2)); assertThat(steps.get(0), equalTo(rawPart(0, Keyword.Unknown, "\n\n", null))); assertThat(steps.get(1), equalTo(rawPart(2, Keyword.Given, " With a simple step", "With"))); }
@Before public void setUp() { specIt = new SpecIt(); specIt .withAlias(Keyword.Scenario, "Scenario:") .withAlias(Keyword.Given, "Given") .withAlias(Keyword.When, "When") .withAlias(Keyword.Then, "Then") .withAliases(Keyword.And, "And", "But") .withAlias(Keyword.Fragment, "Fragment:") .withAlias(Keyword.Repeat, "Repeat"); }