JBehave
  1. JBehave
  2. JBEHAVE-655

Title before "Scenario" ends up as package name

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 3.5.4
    • Fix Version/s: 3.6
    • Labels:
      None
    • Environment:
      jenkins 1.442, Jenkins xUnit plugin 1.32, JBehave Jenkins Plugin 3.5.4
    • Number of attachments :
      0

      Description

      When I run a story that has a comment as the first line of the text, the jbehave/xunit display in Jenkins takes the comment as test name and misses the story file name.

      {{!-- comment

      Scenario: User visits home page

      !-- a very simple test

      Given user is on Home page
      Then Home page is shown
      }}

      the resulting path is then (root)/!-- comment/User visits home page

        Activity

        Hide
        Mauro Talevi added a comment -

        Comments are treated by JBehave as ignorable steps, but only if they appear in a scenario. Anything before a Scenario keyword is not consider a step, and it depends on the context. If nothing else is present, it'll end up being part of the story description.

        Show
        Mauro Talevi added a comment - Comments are treated by JBehave as ignorable steps, but only if they appear in a scenario. Anything before a Scenario keyword is not consider a step, and it depends on the context. If nothing else is present, it'll end up being part of the story description.
        Hide
        Alexander Lehmann added a comment -

        the xml result file looks corrent, I assume that the conversion to junit is wrong.

        <story path="webpage.story" title="!-- comment">
        <scenario keyword="Scenario:" title="User visits home page">
        <step outcome="ignorable">!-- a very simple test</step>
        <step outcome="successful">Given user is on Home page</step>
        <step outcome="successful">Then Home page is shown</step>
        </scenario>
        </story>

        Show
        Alexander Lehmann added a comment - the xml result file looks corrent, I assume that the conversion to junit is wrong. <story path="webpage.story" title="!-- comment"> <scenario keyword="Scenario:" title="User visits home page"> <step outcome="ignorable">!-- a very simple test</step> <step outcome="successful">Given user is on Home page</step> <step outcome="successful">Then Home page is shown</step> </scenario> </story>
        Hide
        Alexander Lehmann added a comment -

        The problem comes from the conversion of the jbehave xml to junit xml (jbehave-3.x-to-junit.xsl), this contains the following rule:

        <xsl:variable name="storyTitle">
        <xsl:choose>
        <xsl:when test="string(//story/@title)">
        <xsl:value-of select="//story/@title" />
        </xsl:when>
        <xsl:otherwise>
        <xsl:value-of select="//story/@path" />
        </xsl:otherwise>
        </xsl:choose>
        </xsl:variable>

        this will put story/title into the testsuite/name attribute which usually contains the full classname of the test class (e.g. org.jbehave.core.steps.StepsBehaviour), this is evaluated in the xunit plugin as the package and classname of the test.

        Now, if title contains a commment or description, the package is empty (i.e. (root)) and the classname is the complete string contained in the title attribute. If the title is empty however, the testsuite/name attribute contains the path of the story file (e.g. org/jbehave/stories/sometest.story), which looks ok in the xunit display.

        I would suggest to always use the path attribute, but I'm not quite sure how the xsl rule was intended, maybe whoever wrote the xsl can comment on that.

        Show
        Alexander Lehmann added a comment - The problem comes from the conversion of the jbehave xml to junit xml (jbehave-3.x-to-junit.xsl), this contains the following rule: <xsl:variable name="storyTitle"> <xsl:choose> <xsl:when test="string(//story/@title)"> <xsl:value-of select="//story/@title" /> </xsl:when> <xsl:otherwise> <xsl:value-of select="//story/@path" /> </xsl:otherwise> </xsl:choose> </xsl:variable> this will put story/title into the testsuite/name attribute which usually contains the full classname of the test class (e.g. org.jbehave.core.steps.StepsBehaviour), this is evaluated in the xunit plugin as the package and classname of the test. Now, if title contains a commment or description, the package is empty (i.e. (root)) and the classname is the complete string contained in the title attribute. If the title is empty however, the testsuite/name attribute contains the path of the story file (e.g. org/jbehave/stories/sometest.story), which looks ok in the xunit display. I would suggest to always use the path attribute, but I'm not quite sure how the xsl rule was intended, maybe whoever wrote the xsl can comment on that.
        Hide
        Alexander Lehmann added a comment -

        The correct title for the issue is probably "Title text before Scenario ends up as package name in jbehave-plugin-jenkins"

        I have changed the xsl to always use the path name and added a test for that

        Show
        Alexander Lehmann added a comment - The correct title for the issue is probably "Title text before Scenario ends up as package name in jbehave-plugin-jenkins" I have changed the xsl to always use the path name and added a test for that
        Show
        Alexander Lehmann added a comment - https://github.com/alexlehm/jbehave-core/commit/31bf5eb77c56a166fcc93d159d6fbcd4cae01f53
        Mauro Talevi made changes -
        Field Original Value New Value
        Summary a comment before "Scenario" ends up as package name in jbehave-plugin-jenkins Title before "Scenario" ends up as package name
        Fix Version/s 3.6 [ 17721 ]
        Component/s Hudson Support [ 14606 ]
        Mauro Talevi made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]

          People

          • Assignee:
            Unassigned
            Reporter:
            Alexander Lehmann
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: