JBehave
  1. JBehave
  2. JBEHAVE-148

Auto-generate method stubs for pending steps with no parameters

    Details

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

      Description

      Auto-generate method stubs with no parameters. The steps such as

      Given there is a flight
      And there is a customer
      When the customer books the flight
      Then the customer is shown on the manifest

      would generate Java methods like this:

      @Given("there is a flight")
      @Pending
      public void givenThereIsAFlight() {
      }

      @Given("there is a customer") // note 'Given', even though story line is 'And'
      @Pending
      public void givenThereIsACustomer() {
      }

      @When("the customer books the flight")
      @Pending
      public void whenTheCustomerBooksTheFlight() {
      }

      @Then("the customer is shown on the flight manifest")
      @Pending
      public void thenTheCustomerIsShownOnTheFlightManifest() {
      }

      If @Pending annotated methods are already matched the methods should not be re-generated.

        Activity

        Mauro Talevi made changes -
        Field Original Value New Value
        Summary Auto-generate steps from scenario template Auto-generate steps from template
        Assignee Mauro Talevi [ maurotalevi ]
        Fix Version/s 3.4 [ 17278 ]
        Description At the moment, the process of writing the matching Java steps is manual, although automating their generation from the scenario textual template may be useful. It would involve defining a template of scenario steps, e.g.

        Given a condition $condition:Condition
        When an $event:Event
        Then the result is $result:Result

        which would map to methods

        @Given("a condition $condition")
        public void aCondition(Condition condition){
        }

        @When("an event $event")
        public void anEvent(Event event){
        }

        @Then("the result is $result")
        public void theResultIs(Result result){
        }

        Note that the template must specify the name and type of the parameter (with a given convention, e.g. colon separated).

        We'd also need to come up with some "runner", that can play well both in IDE and in CLI. Something like a Template, akin to Scenario, that would match the match the template name (like scenario files match the scenario class).


        Automated the process of writing the matching Java steps by auto-generating stubs for steps from template. It would involve defining a template of steps that specifies the name and type of the parameter (with a given convention, such as colon separated). So, e.g.

        Given a condition $condition:Condition
        When an $event:Event
        Then the result is $result:Result

        which would map steps

        Given a condition aCondition
        When an anEvent
        Then the result is aResult

        to methods

        @Given("a condition $condition")
        public void aCondition(Condition condition){
        }

        @When("an event $event")
        public void anEvent(Event event){
        }

        @Then("the result is $result")
        public void theResultIs(Result result){
        }

        We'd also need to decide how to integrated with existing step execution. We could output the generated steps via a bespoke reporter Format.

        Mauro Talevi made changes -
        Summary Auto-generate steps from template Auto-generate method stubs for pending steps
        Mauro Talevi made changes -
        Status Open [ 1 ] In Progress [ 3 ]
        Mauro Talevi made changes -
        Summary Auto-generate method stubs for pending steps Auto-generate method stubs for pending steps with no parameters
        Issue Type New Feature [ 2 ] Improvement [ 4 ]
        Description Automated the process of writing the matching Java steps by auto-generating stubs for steps from template. It would involve defining a template of steps that specifies the name and type of the parameter (with a given convention, such as colon separated). So, e.g.

        Given a condition $condition:Condition
        When an $event:Event
        Then the result is $result:Result

        which would map steps

        Given a condition aCondition
        When an anEvent
        Then the result is aResult

        to methods

        @Given("a condition $condition")
        public void aCondition(Condition condition){
        }

        @When("an event $event")
        public void anEvent(Event event){
        }

        @Then("the result is $result")
        public void theResultIs(Result result){
        }

        We'd also need to decide how to integrated with existing step execution. We could output the generated steps via a bespoke reporter Format.

        Auto-generate method stubs with no parameters. The steps such as

        Given there is a flight
        And there is a customer
        When the customer books the flight
        Then the customer is shown on the manifest

        would generate Java methods like this:

        @Given("there is a flight")
        @Pending
        public void givenThereIsAFlight() {
        }

        @Given("there is a customer") // note 'Given', even though story line is 'And'
        @Pending
        public void givenThereIsACustomer() {
        }

        @When("the customer books the flight")
        @Pending
        public void whenTheCustomerBooksTheFlight() {
        }

        @Then("the customer is shown on the flight manifest")
        @Pending
        public void thenTheCustomerIsShownOnTheFlightManifest() {
        }

        If @Pending annotated methods are already matched the methods should not be re-generated.
        Mauro Talevi made changes -
        Status In Progress [ 3 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Mauro Talevi made changes -
        Fix Version/s 3.3.1 [ 17301 ]

          People

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

            Dates

            • Created:
              Updated:
              Resolved: