JBehave
  1. JBehave
  2. JBEHAVE-975

Keyword Synonyms cause failure to find And Steps in same class

    Details

    • Type: Bug Bug
    • Status: Open Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 3.9
    • Fix Version/s: None
    • Component/s: Core
    • Labels:
      None
    • Number of attachments :
      1

      Description

      I started to use Keyword Synonyms to allow steps to be found like 'Given|GIVEN|given' etc.
      I used a custom keywords bundle (see attachments) which worked correctly and found my custom keywords as expected.
      However I cannot now find steps annotated like this :

      @Then("I navigate to admin page")
      @Given("I am on the admin page and logged in")
      public static void loggedIntoAdmin()

      { AdminPage.login(); }

      The JIRA text is :
      Given a given customer is selected
      And I am on the admin page and logged in

      Note : The Given step and the And Step are in the same class.

      This works fine if I do not use Synonyms on the Given step.

        Activity

        Hide
        Mauro Talevi added a comment -

        It's got nothing to do with synonyms. You're not finding the And step because you're annotating the same method both as @Then and a @When. It's finding it as a Then step and therefore not matching the And - which following Given is interpreted as another Given.

        Methods are meant to be annotated only by one of @Given @When or @Then.

        Show
        Mauro Talevi added a comment - It's got nothing to do with synonyms. You're not finding the And step because you're annotating the same method both as @Then and a @When. It's finding it as a Then step and therefore not matching the And - which following Given is interpreted as another Given. Methods are meant to be annotated only by one of @Given @When or @Then.
        Hide
        Darragh Grace added a comment -

        Thanks Mauro, That's what I was thinking. But if I don't use Synonyms, in the above situation jbehave will find @Given("I am on the admin page and logged in") as an @And step. It does not matter to it that the same method is annotated as @Then & @Given. Just an fyi.

        Show
        Darragh Grace added a comment - Thanks Mauro, That's what I was thinking. But if I don't use Synonyms, in the above situation jbehave will find @Given("I am on the admin page and logged in") as an @And step. It does not matter to it that the same method is annotated as @Then & @Given. Just an fyi.
        Hide
        Darragh Grace added a comment -

        Actually, on more investigation it has nothing to do with the method annotated as a @Given and @Then.
        If I take away the @When annotation on this method and leave just the @Given annotation and use Synonyms for Given (Given=Given|GIVEN|given), the @And step is still not found. If I don't use Synonyms for Given (Given=Given) then the method is found as an @And step.

        // @Then annotation is removed
        @Given("I am on the admin page and logged in")
        public static void loggedIntoAdmin()

        { AdminPage.login(); }
        Show
        Darragh Grace added a comment - Actually, on more investigation it has nothing to do with the method annotated as a @Given and @Then. If I take away the @When annotation on this method and leave just the @Given annotation and use Synonyms for Given (Given=Given|GIVEN|given), the @And step is still not found. If I don't use Synonyms for Given (Given=Given) then the method is found as an @And step. // @Then annotation is removed @Given("I am on the admin page and logged in") public static void loggedIntoAdmin() { AdminPage.login(); }
        Hide
        Mauro Talevi added a comment -

        Could you please attach a simple project to reproduce this behaviour?

        Show
        Mauro Talevi added a comment - Could you please attach a simple project to reproduce this behaviour?

          People

          • Assignee:
            Unassigned
            Reporter:
            Darragh Grace
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated: