JBehave
  1. JBehave
  2. JBEHAVE-163

Support comments in plain-text scenarios

    Details

    • Type: New Feature New Feature
    • Status: Resolved Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.4
    • Fix Version/s: 2.4.1, 2.5
    • Component/s: Core
    • Labels:
      None
    • Number of attachments :
      0

      Description

      It would be nice to have the ability to add comments in the plain-test scenarios. If we add any comments, the parser thinks they are the continuation of the previous line. To have comment support so that all lines preceded by # or – or whatever get ignored, that would be a nice feature.

        Activity

        Hide
        Mauro Talevi added a comment -

        Currently, comments can be placed in the scenario text file, either before the Scenario keyword, or as the description of the scenario, ie between the Scenario and the first of the other keywords.

        Show
        Mauro Talevi added a comment - Currently, comments can be placed in the scenario text file, either before the Scenario keyword, or as the description of the scenario, ie between the Scenario and the first of the other keywords.
        Mauro Talevi made changes -
        Field Original Value New Value
        Fix Version/s 2.3 [ 14941 ]
        Fix Version/s 2.2 [ 14670 ]
        Mauro Talevi made changes -
        Summary Support comments in plain-test scenarios Support comments in plain-text scenarios
        Mauro Talevi made changes -
        Fix Version/s 2.4 [ 15664 ]
        Fix Version/s 2.3 [ 14941 ]
        Mauro Talevi made changes -
        Fix Version/s 2.4 [ 15664 ]
        Fix Version/s 2.5 [ 15850 ]
        Hide
        Jonathan Ross added a comment -

        Unfortunately, if the step preceding the comment ends with a variable, the pattern matcher gets greedy...

        I would also like to be able to use comments between steps, and the only work-around I have currently is to avoid ending a step annotation with a variable - this doesn't always lead to natural prose!

        Some solutions I can come up with:
        1. add a commas or period followed by a new line to the syntax as step delimiters, e.g.
        Given a comma or period after a $variable,
        i can put a comment here without it being swallowed by the pattern matcher,
        And i can proceed with the scenario.
        2. provide regexp support in the step annotations, e.g.:
        @Before("Given a step matching a variable at the end, like so: $([^\n]*)")
        3. provide another mechanism for distinguishing between single and multi-line variables
        4. add comment prefixes as suggested by the original post

        Show
        Jonathan Ross added a comment - Unfortunately, if the step preceding the comment ends with a variable, the pattern matcher gets greedy... I would also like to be able to use comments between steps, and the only work-around I have currently is to avoid ending a step annotation with a variable - this doesn't always lead to natural prose! Some solutions I can come up with: 1. add a commas or period followed by a new line to the syntax as step delimiters, e.g. Given a comma or period after a $variable, i can put a comment here without it being swallowed by the pattern matcher, And i can proceed with the scenario. 2. provide regexp support in the step annotations, e.g.: @Before("Given a step matching a variable at the end, like so: $( [^\n] *)") 3. provide another mechanism for distinguishing between single and multi-line variables 4. add comment prefixes as suggested by the original post
        Mauro Talevi made changes -
        Affects Version/s 2.2 [ 14670 ]
        Affects Version/s 2.3 [ 14941 ]
        Fix Version/s 2.4.1 [ 16188 ]
        Component/s Core [ 11086 ]
        Mauro Talevi made changes -
        Assignee Mauro Talevi [ maurotalevi ]
        Hide
        Mauro Talevi added a comment -

        Added ignorable step type to allow comments, between steps:

        Given a given step
        !-- this is a comment, which will be ignored
        Then a then step

        Default ignorable step keyword (!--) can be overridden as any keyword.

        Show
        Mauro Talevi added a comment - Added ignorable step type to allow comments, between steps: Given a given step !-- this is a comment, which will be ignored Then a then step Default ignorable step keyword (!--) can be overridden as any keyword.
        Mauro Talevi made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Mauro Talevi made changes -
        Affects Version/s 2.4 [ 15664 ]
        Affects Version/s 2.3 [ 14941 ]
        Hide
        Mauro Talevi added a comment - - edited

        As fully-fledged steps (which are simply ignored in the execution process) ignorable steps retain the very useful feature of appearing on the reporting side, exactly in the order in which they were found in the textual scenario.

        Show
        Mauro Talevi added a comment - - edited As fully-fledged steps (which are simply ignored in the execution process) ignorable steps retain the very useful feature of appearing on the reporting side, exactly in the order in which they were found in the textual scenario.
        Hide
        Francis Alcala added a comment - - edited

        Is there a way to comment on the data rows ( under the Examples: keyword)?
        I would like to comment out some data rows. So that I could just remove the comments whenever the rows would again be needed.
        Currently, the !-- doesn't work on the data rows.
        Thanks.

        Show
        Francis Alcala added a comment - - edited Is there a way to comment on the data rows ( under the Examples: keyword)? I would like to comment out some data rows. So that I could just remove the comments whenever the rows would again be needed. Currently, the !-- doesn't work on the data rows. Thanks.
        Hide
        Mauro Talevi added a comment -

        Yes, comments in tables are allowed using the "|--" symbol :

        http://jbehave.org/reference/stable/javadoc/core/org/jbehave/core/model/ExamplesTable.html

        Show
        Mauro Talevi added a comment - Yes, comments in tables are allowed using the "|--" symbol : http://jbehave.org/reference/stable/javadoc/core/org/jbehave/core/model/ExamplesTable.html
        Hide
        Francis Alcala added a comment -

        Thanks Mauro for the quick reply!

        Show
        Francis Alcala added a comment - Thanks Mauro for the quick reply!

          People

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

            Dates

            • Created:
              Updated:
              Resolved: