JBehave
  1. JBehave
  2. JBEHAVE-853

Jenkins plugin cannot parse xml files with narrative tag

    Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Not A Bug
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Number of attachments :
      1

      Description

      If a story file contains <narrative> tag, then the generated xml report will look like the following:

      <narrative keyword="Narrative:">
        <inOrderTo keyword="In order to">do something</inOrderTo>
        <asA keyword="As a">user</asA>
        <iWantTo keyword="I want to">be able to do something else</iWantTo>
      </narrative>
      <story path="story1.story" title="It should do something">
      ...
      </story>
      

      Jenkins plugin cannot parse files like this, log

      INFO: [xUnit] - Converting '/path/to/jenkins/job/workspace/target/jbehave/story1.xml' .
      [Fatal Error] :6:2: The markup in the document following the root element must be well-formed.
      com.thalesgroup.hudson.plugins.xunit.exception.XUnitException: Conversion error Error to convert - A file not found
      

      Line 6 points to the starting <story> tag, which comes after the closing </narrative> tag.

        Activity

        Hide
        Alexander Lehmann added a comment -

        I think there were a few errors with xml fixed in or before 3.7, which version are you currently using?

        Maybe we missing some cases though.

        Show
        Alexander Lehmann added a comment - I think there were a few errors with xml fixed in or before 3.7, which version are you currently using? Maybe we missing some cases though.
        Hide
        Zihao Yu added a comment -

        jbehave-core 3.7.3
        jbehave-jenkins-plugin 3.7.3

        Show
        Zihao Yu added a comment - jbehave-core 3.7.3 jbehave-jenkins-plugin 3.7.3
        Hide
        Alexander Lehmann added a comment -

        then it's definitely a new bug.

        I cannot reproduce the problem with a sample story I tried, can you please post a shortened sample story that gives you broken XML?

        Show
        Alexander Lehmann added a comment - then it's definitely a new bug. I cannot reproduce the problem with a sample story I tried, can you please post a shortened sample story that gives you broken XML?
        Hide
        Zihao Yu added a comment -

        story1.story

        This is a test story
        
        Narrative:
        In order to do some test
        As a user
        I want to be able to use jbehave
        
        Scenario: User should know how to download jbehave
        
        Meta:
        @id story1scenario1
        
        Given a user
        When he is asked to download jbehave
        Then he should know how to do it
        

        Story1Steps.java

        import org.jbehave.core.annotations.Given;
        import org.jbehave.core.annotations.Then;
        import org.jbehave.core.annotations.When;
        
        import static org.junit.Assert.assertEquals;
        
        public class Story1Steps {
        
            @Given("a user")
            public void setUser() {
                assertEquals("user", "user");
            }
        
            @When("he is asked to download jbehave")
            public void downloadJbehave() {
                assertEquals("jbehave", "jbehave");
            }
        
            @Then("he should know how to do it")
            public void isDownloaded() {
                assertEquals("downloaded", "downloaded");
            }
        
        }
        

        After running jbehave maven task,
        story1.xml

        <narrative keyword="Narrative:">
          <inOrderTo keyword="In order to">do some test</inOrderTo>
          <asA keyword="As a">user</asA>
          <iWantTo keyword="I want to">be able to use jbehave</iWantTo>
        </narrative>
        <story path="story1.story" title="This is a test story">
          <scenario keyword="Scenario:" title="User should know how to download jbehave">
            <step outcome="successful">Given a user</step>
            <step outcome="successful">When he is asked to download jbehave</step>
            <step outcome="successful">Then he should know how to do it</step>
          </scenario>
        </story>
        

        Jenkins throws exception,

        [xUnit] [ERROR] - Conversion error Error to convert - A file not found
        ERROR: Publisher org.jenkinsci.plugins.xunit.XUnitPublisher aborted due to exception
        hudson.util.IOException2: There are some problems during the conversion into JUnit reports: 
        	at com.thalesgroup.hudson.plugins.xunit.service.XUnitTransformer.invoke(XUnitTransformer.java:164)
        

        Jenkins log,

        INFO: [xUnit] - Converting '/Users/zyu/.jenkins/jobs/jbehave-poc/workspace/target/jbehave/story1.xml' .
        [Fatal Error] :6:2: The markup in the document following the root element must be well-formed.
        com.thalesgroup.hudson.plugins.xunit.exception.XUnitException: Conversion error Error to convert - A file not found
                at com.thalesgroup.hudson.plugins.xunit.service.XUnitConversionService.convert(XUnitConversionService.java:89)
        
        Show
        Zihao Yu added a comment - story1.story This is a test story Narrative: In order to do some test As a user I want to be able to use jbehave Scenario: User should know how to download jbehave Meta: @id story1scenario1 Given a user When he is asked to download jbehave Then he should know how to do it Story1Steps.java import org.jbehave.core.annotations.Given; import org.jbehave.core.annotations.Then; import org.jbehave.core.annotations.When; import static org.junit.Assert.assertEquals; public class Story1Steps { @Given( "a user" ) public void setUser() { assertEquals( "user" , "user" ); } @When( "he is asked to download jbehave" ) public void downloadJbehave() { assertEquals( "jbehave" , "jbehave" ); } @Then( "he should know how to do it" ) public void isDownloaded() { assertEquals( "downloaded" , "downloaded" ); } } After running jbehave maven task, story1.xml <narrative keyword= "Narrative:" > <inOrderTo keyword= "In order to" > do some test</inOrderTo> <asA keyword= "As a" >user</asA> <iWantTo keyword= "I want to" >be able to use jbehave</iWantTo> </narrative> <story path= "story1.story" title= "This is a test story" > <scenario keyword= "Scenario:" title= "User should know how to download jbehave" > <step outcome= "successful" >Given a user</step> <step outcome= "successful" >When he is asked to download jbehave</step> <step outcome= "successful" >Then he should know how to do it</step> </scenario> </story> Jenkins throws exception, [xUnit] [ERROR] - Conversion error Error to convert - A file not found ERROR: Publisher org.jenkinsci.plugins.xunit.XUnitPublisher aborted due to exception hudson.util.IOException2: There are some problems during the conversion into JUnit reports: at com.thalesgroup.hudson.plugins.xunit.service.XUnitTransformer.invoke(XUnitTransformer.java:164) Jenkins log, INFO: [xUnit] - Converting '/Users/zyu/.jenkins/jobs/jbehave-poc/workspace/target/jbehave/story1.xml' . [Fatal Error] :6:2: The markup in the document following the root element must be well-formed. com.thalesgroup.hudson.plugins.xunit.exception.XUnitException: Conversion error Error to convert - A file not found at com.thalesgroup.hudson.plugins.xunit.service.XUnitConversionService.convert(XUnitConversionService.java:89)
        Hide
        Alexander Lehmann added a comment -

        strange, the story works for me, I'm getting

        <story path="my.story" title="This is a test story">
        <narrative keyword="Narrative:">
          <inOrderTo keyword="In order to">do some test</inOrderTo>
          <asA keyword="As a">user</asA>
          <iWantTo keyword="I want to">be able to use jbehave</iWantTo>
        </narrative>
        <scenario keyword="Scenario:" title="User should know how to download jbehave">
        <meta>
        <property keyword="@" name="id" value="story1scenario1"/>
        </meta>
        <step outcome="successful">Given a user</step>
        <step outcome="successful">When he is asked to download jbehave</step>
        <step outcome="successful">Then he should know how to do it</step>
        </scenario>
        </story>
        

        Can you please post either a source zip or the compiled jar (e.g. maven package), so I can check what I am doing differently?

        Show
        Alexander Lehmann added a comment - strange, the story works for me, I'm getting <story path= "my.story" title= "This is a test story" > <narrative keyword= "Narrative:" > <inOrderTo keyword= "In order to" > do some test </inOrderTo> <asA keyword= "As a" > user </asA> <iWantTo keyword= "I want to" > be able to use jbehave </iWantTo> </narrative> <scenario keyword= "Scenario:" title= "User should know how to download jbehave" > <meta> <property keyword= "@" name= "id" value= "story1scenario1" /> </meta> <step outcome= "successful" > Given a user </step> <step outcome= "successful" > When he is asked to download jbehave </step> <step outcome= "successful" > Then he should know how to do it </step> </scenario> </story> Can you please post either a source zip or the compiled jar (e.g. maven package), so I can check what I am doing differently?
        Hide
        Zihao Yu added a comment -

        Demo tests.

        Show
        Zihao Yu added a comment - Demo tests.
        Zihao Yu made changes -
        Field Original Value New Value
        Attachment bdd-core.zip [ 61990 ]
        Zihao Yu made changes -
        Attachment bdd-core.zip [ 61990 ]
        Hide
        Zihao Yu added a comment -

        I uploaded a simple test in zip. Confidential content was removed.

        Show
        Zihao Yu added a comment - I uploaded a simple test in zip. Confidential content was removed.
        Zihao Yu made changes -
        Attachment bdd-core.zip [ 61991 ]
        Hide
        Alexander Lehmann added a comment - - edited

        Though this is not obvious to detect from the pom file, but you are running your tests with version 4.0-beta-2 due to automatic version detection by maven.
        This version is actually broken and creates incorrect xml.
        To switch back to 3.7.3 which works for the xml, you have to add the version line in your pom:

        <artifactId>jbehave-maven-plugin</artifactId>
        <version>${jbehave.core.version}</version>
        <executions>
        

        If the version line is ommited, maven will look for the most current version of the plugin that is available (which is 4.0-beta-2 currently) and load the dependencies with the same version (jbehave-core-4.0-beta-2.jar).
        Even though the build process will use 3.7.3 (and e.g. Eclipse will display that as Maven Dependencies and run the unit test with it), the tests are then run with 4.0-beta.

        Show
        Alexander Lehmann added a comment - - edited Though this is not obvious to detect from the pom file, but you are running your tests with version 4.0-beta-2 due to automatic version detection by maven. This version is actually broken and creates incorrect xml. To switch back to 3.7.3 which works for the xml, you have to add the version line in your pom: <artifactId>jbehave-maven-plugin</artifactId> <version>${jbehave.core.version}</version> <executions> If the version line is ommited, maven will look for the most current version of the plugin that is available (which is 4.0-beta-2 currently) and load the dependencies with the same version (jbehave-core-4.0-beta-2.jar). Even though the build process will use 3.7.3 (and e.g. Eclipse will display that as Maven Dependencies and run the unit test with it), the tests are then run with 4.0-beta.
        Hide
        Zihao Yu added a comment -

        Thanks! That solved the problem.

        Show
        Zihao Yu added a comment - Thanks! That solved the problem.
        Hide
        Zihao Yu added a comment -

        Added jbehave-maven-plugin version to resolve issue.

        Show
        Zihao Yu added a comment - Added jbehave-maven-plugin version to resolve issue.
        Zihao Yu made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Not A Bug [ 6 ]

          People

          • Assignee:
            Unassigned
            Reporter:
            Zihao Yu
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: