JBehave
  1. JBehave
  2. JBEHAVE-764

Allow comments between scenarios in JBehave story files.

    Details

    • Type: Improvement Improvement
    • Status: Open Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 3.6.1
    • Fix Version/s: None
    • Component/s: Core
    • Labels:
      None
    • Patch Submitted:
      Yes
    • Number of attachments :
      1

      Description

      Hi,

      Our story file contains aprox. 30 scenarios, they are logically divided into groups. We would like to have possibility to split those groups in story files using comments.
      So after every 3-4 scenarios we would like to add comments indicating that new section has begun. I've played little bit with Jbehave RegexStoryParser and all that need to be done is
      change of "public Story parseStory(String storyAsText, String storyPath)" method.Please see attached code snippet from overridedn RegexStoryParser

        Activity

        Hide
        Maciej Madej added a comment -

        Patched RegexStoryParser

        Show
        Maciej Madej added a comment - Patched RegexStoryParser
        Maciej Madej made changes -
        Field Original Value New Value
        Attachment RegexStoryRemovingCommentsParser.java [ 59551 ]
        Hide
        Mauro Talevi added a comment -

        Comments are an integral part of the story (ignorable steps) and cannot be removed. They are shown in the report outputs.

        If you want to put comments between scenarios, why not use the free-text scenario title for this purpose?

        Show
        Mauro Talevi added a comment - Comments are an integral part of the story (ignorable steps) and cannot be removed. They are shown in the report outputs. If you want to put comments between scenarios, why not use the free-text scenario title for this purpose?
        Hide
        Maciej Madej added a comment -

        Hmm, Scenario title represents specific scenario for given component. Couple of next scenarios are for the same compoenent. I just want to indicate that starting scenarios for given compoents have started. Example story file:

        !--### Receive compoenent###

        Scenario: Receieve A message
        Given...
        When...
        Then...

        Scenario: Receive B message
        Given...
        When...
        Then...

        !-- # Processing component###

        Scenario: Process A message
        Given....
        When...
        Then...

        Scenario: Process B message
        Given...
        When..
        Then..

        I guess comments should be integral part of any DSL on every level of it. Thanks to above comments it's more readable to browse story file.

        Show
        Maciej Madej added a comment - Hmm, Scenario title represents specific scenario for given component. Couple of next scenarios are for the same compoenent. I just want to indicate that starting scenarios for given compoents have started. Example story file: !--### Receive compoenent### Scenario: Receieve A message Given... When... Then... Scenario: Receive B message Given... When... Then... !-- # Processing component### Scenario: Process A message Given.... When... Then... Scenario: Process B message Given... When.. Then.. I guess comments should be integral part of any DSL on every level of it. Thanks to above comments it's more readable to browse story file.
        Hide
        Mauro Talevi added a comment -

        Have you tried using meta info:

        Scenario: Ping
        Meta: @component send

        Scenario: Pong
        Meta: @component receive

        Show
        Mauro Talevi added a comment - Have you tried using meta info: Scenario: Ping Meta: @component send Scenario: Pong Meta: @component receive
        Hide
        Maciej Madej added a comment -

        Yes, I've tried it, the problem is that file is very big (40-50 scenarios). Scrolling the file I cannot say which component section have just started. And another thing is that meta tag probably will need to be added to every scenario. Well I can live with my workarround, I just thought that having comments on every level in story file is something basic.

        Show
        Maciej Madej added a comment - Yes, I've tried it, the problem is that file is very big (40-50 scenarios). Scrolling the file I cannot say which component section have just started. And another thing is that meta tag probably will need to be added to every scenario. Well I can live with my workarround, I just thought that having comments on every level in story file is something basic.
        Hide
        Brian Repko added a comment -

        Even if those comments parse they are part of the Scenario above them as a Story, once we get into Scenarios, is just a group of Scenarios. The real improvement is introducing the notion of "Scenario Groups". But doing those properly would require a change to the domain as well as new lifecycle annotations @Before@AfterScenarioGroup etc. Its not just a simple parser change to do this properly.

        Or are we missing an interface that would allow you to override the standard behavior?

        So, I'm curious, why not convert the groups into stories but group them on the file system in one folder?

        Show
        Brian Repko added a comment - Even if those comments parse they are part of the Scenario above them as a Story, once we get into Scenarios, is just a group of Scenarios. The real improvement is introducing the notion of "Scenario Groups". But doing those properly would require a change to the domain as well as new lifecycle annotations @Before@AfterScenarioGroup etc. Its not just a simple parser change to do this properly. Or are we missing an interface that would allow you to override the standard behavior? So, I'm curious, why not convert the groups into stories but group them on the file system in one folder?
        Hide
        Mauro Talevi added a comment -

        I agree with Brian that the real usecase here seems to be a scenario grouping one, which would bring greater overall advantage than simple comments sprinkled between scenarios.

        Show
        Mauro Talevi added a comment - I agree with Brian that the real usecase here seems to be a scenario grouping one, which would bring greater overall advantage than simple comments sprinkled between scenarios.

          People

          • Assignee:
            Unassigned
            Reporter:
            Maciej Madej
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: