JBehave
  1. JBehave
  2. JBEHAVE-196

Candidate steps should be aware of the method annotation type when matching textual steps

    Details

    • Type: Improvement Improvement
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.3
    • Fix Version/s: 2.3.1, 2.4
    • Component/s: Core
    • Labels:
      None
    • Number of attachments :
      0

      Description

      Candidate steps should be aware of annotations @Given, @When and @Then and distinguish pattern steps arising from different annotations.
      At present, there is no such distinction and can lead to very confusing behaviour.
      Example:
      @Given("foo named $name")
      public void givenFoo(String name)

      {...}
      @When("foo named $name is created")
      public void createFoo{...}

      If I have a scenario like this:
      Scenario: Do stuff
      Given xyz
      When foo named Bar is created
      ...
      then the "When" can match the givenFoo() method, which gets passed "Bar is created" as parameter.

      This unexpected behaviour, due to the implict uniqueness required of the matching pattern across all annotations, causes randomness in test execution. Sometimes it works, sometimes it doesn't. It would be better if the different annotations where treated differently in the matching of patterns, so that when I write Given/When/Then in the scenarios they will match corresponding @Given/@When/@Then methods.

        Activity

        Hide
        Mauro Talevi added a comment -

        Reworded to better express current behaviour and new feature requirement.

        Show
        Mauro Talevi added a comment - Reworded to better express current behaviour and new feature requirement.
        Mauro Talevi made changes -
        Field Original Value New Value
        Fix Version/s 2.4 [ 15664 ]
        Issue Type Bug [ 1 ] Improvement [ 4 ]
        Description In general, words should have meanings. For JBehave, if I use the annotations @Given, @When and @Then, they should mean different things. Right now there is no difference, which can lead to very confusing behaviour.
        Example:
        @Given("foo named $name")
        public void givenFoo(String name) {...}
        @When("foo named $name is created")
        public void createFoo{...}

        If I have a scenario like this:
        Scenario: Do stuff
        Given xyz
        When foo named Bar is created
        ...
        then the "When" can match the givenFoo() method, which gets passed "Bar is created" as parameter.

        This unexpected behaviour, due to words not having any meaning, causes randomness in test execution. Sometimes it works, sometimes it doesn't. It would be better if the different annotations had separate meanings, so that when I write Given/When/Then in the scenarios they will match corresponding @Given/@When/@Then methods.
        Candidate steps should be aware of annotations @Given, @When and @Then and distinguish pattern steps arising from different annotations.
        At present, there is no such distinction and can lead to very confusing behaviour.
        Example:
        @Given("foo named $name")
        public void givenFoo(String name) {...}
        @When("foo named $name is created")
        public void createFoo{...}

        If I have a scenario like this:
        Scenario: Do stuff
        Given xyz
        When foo named Bar is created
        ...
        then the "When" can match the givenFoo() method, which gets passed "Bar is created" as parameter.

        This unexpected behaviour, due to the implict uniqueness required of the matching pattern across all annotations, causes randomness in test execution. Sometimes it works, sometimes it doesn't. It would be better if the different annotations where treated differently in the matching of patterns, so that when I write Given/When/Then in the scenarios they will match corresponding @Given/@When/@Then methods.
        Summary Words should have meanings Candidate steps should be aware of the method annotation type when matching textual steps
        Mauro Talevi made changes -
        Assignee Mauro Talevi [ maurotalevi ]
        Mauro Talevi made changes -
        Status Open [ 1 ] In Progress [ 3 ]
        Hide
        Mauro Talevi added a comment -

        Introduced StepType enum and refactored CandidateStep to be aware of type. The starting word must now match the type (in the appropriate locale).

        Deprecated the Steps(String[] startingWords) constructors as these cannot resolve the word by type.

        Show
        Mauro Talevi added a comment - Introduced StepType enum and refactored CandidateStep to be aware of type. The starting word must now match the type (in the appropriate locale). Deprecated the Steps(String[] startingWords) constructors as these cannot resolve the word by type.
        Mauro Talevi made changes -
        Fix Version/s 2.3.1 [ 15921 ]
        Mauro Talevi made changes -
        Resolution Fixed [ 1 ]
        Status In Progress [ 3 ] Resolved [ 5 ]

          People

          • Assignee:
            Mauro Talevi
            Reporter:
            Rickard Oberg
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: