JBehave
  1. JBehave
  2. JBEHAVE-338

Indented scenarios in stories was possible in JB2 but after upgrade failed in JB3

    Details

    • Type: Bug Bug
    • Status: Open Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 3.0
    • Fix Version/s: None
    • Component/s: Core
    • Labels:
      None
    • Environment:
      Windows
    • Number of attachments :
      0

      Description

      A client had indented JB scenarios (tabs and/or spaces) in the .scenario files. When upgraded to JB3, and everything else was working for the renamed .story files. the scenarios were not being executed. It seems regex made no match.

      We had breakpoints in place so we could see the BeforeScenario being invoked, but none of the steps. When we removed the left-whitespace, it worked.

        Activity

        Hide
        Brian Repko added a comment -

        I believe that this had to do with the change to support i18n'd keywords that in some languages are smaller (y in Spanish and e in Italian) and a shift to look for those at the beginning of the line (if I remember correctly). Just want to mention that so that we don't break the work that was done before.

        Show
        Brian Repko added a comment - I believe that this had to do with the change to support i18n'd keywords that in some languages are smaller (y in Spanish and e in Italian) and a shift to look for those at the beginning of the line (if I remember correctly). Just want to mention that so that we don't break the work that was done before.
        Hide
        Mauro Talevi added a comment -

        Brian is quite right - this is not a regression, rather a feature (JBEHAVE-325).

        It is also documented in http://jbehave.org/reference/stable/migrating-from-2.x.html

        The usecase of indented scenarios is quite rare and is outweighted by the advantage of allowing keyword in comments, titles, tables etc ...

        If one wants to keep at all costs tabs/spaces before keywords, a possible workaround would be writing a pre-parser that strips these tabs/spaces before passing it to the RegexStoryParser.

        Show
        Mauro Talevi added a comment - Brian is quite right - this is not a regression, rather a feature ( JBEHAVE-325 ). It is also documented in http://jbehave.org/reference/stable/migrating-from-2.x.html The usecase of indented scenarios is quite rare and is outweighted by the advantage of allowing keyword in comments, titles, tables etc ... If one wants to keep at all costs tabs/spaces before keywords, a possible workaround would be writing a pre-parser that strips these tabs/spaces before passing it to the RegexStoryParser.
        Hide
        Paul Hammant added a comment -

        If there' a reason for it - fine. The HTML output is indented appropriately

        Could we perhaps throw an exception to make more obvious to users not to have leftmost whitespace ?

        Show
        Paul Hammant added a comment - If there' a reason for it - fine. The HTML output is indented appropriately Could we perhaps throw an exception to make more obvious to users not to have leftmost whitespace ?
        Hide
        Mauro Talevi added a comment -

        The notification to users is the fact that the step is not matched as expected and it marked as pending.

        We can't do more than that, even if we wanted. That's the nature of regex parsing.

        Show
        Mauro Talevi added a comment - The notification to users is the fact that the step is not matched as expected and it marked as pending. We can't do more than that, even if we wanted. That's the nature of regex parsing.
        Hide
        Paul Hammant added a comment -

        Au contraire, we could regex for whitespace at the start of a line, *before* we do any other regex for G/W/T (etc):

        For (multiline):

        ^[\x20\x09]+[^\s]

        On:

        hello
        how are
        you
        today?

        It will find the space-space-h sequence and nothing else.

        Show
        Paul Hammant added a comment - Au contraire, we could regex for whitespace at the start of a line, * before * we do any other regex for G/W/T (etc): For (multiline): ^ [\x20\x09] + [^\s] On: hello how are you today? It will find the space-space-h sequence and nothing else.
        Hide
        Mauro Talevi added a comment -

        Yes, it's essentially the pre-parsing concept proposed above.

        But it's probably best done in a decorator class as it's a rather rare corner case to justify it being done by default (would slow down parsing that is already not lighting fast). Anybody wanting to use indentation could simply configure the decorator around the regex story parser.

        Show
        Mauro Talevi added a comment - Yes, it's essentially the pre-parsing concept proposed above. But it's probably best done in a decorator class as it's a rather rare corner case to justify it being done by default (would slow down parsing that is already not lighting fast). Anybody wanting to use indentation could simply configure the decorator around the regex story parser.
        Hide
        Brian Repko added a comment -

        we've already got the configuration around greedy vs non-greedy qualifiers - it might interesting to wrap that together with this in a nice tidy design.

        Show
        Brian Repko added a comment - we've already got the configuration around greedy vs non-greedy qualifiers - it might interesting to wrap that together with this in a nice tidy design.

          People

          • Assignee:
            Unassigned
            Reporter:
            Paul Hammant
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: