Exemplo n.º 1
0
  @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")));
  }
Exemplo n.º 2
0
  @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")));
  }
Exemplo n.º 3
0
  @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")));
  }
Exemplo n.º 4
0
  @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")));
  }
Exemplo n.º 5
0
  @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")));
  }