Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-58369

xUnit Plugin problem with Boost test XML output that contains messages

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      I compile the following minimal C++ Boost test program 

      #define BOOST_TEST_MODULE ExampleTestSuite
      #include <boost/test/included/unit_test.hpp>
      #include <boost/test/unit_test.hpp>
      
      BOOST_AUTO_TEST_SUITE(MyTestSuite_1)
      
      BOOST_AUTO_TEST_CASE(MyTest_1_1) {
          // BOOST_TEST_MESSAGE("Running MyTest_1_1");
          int i = 1;
          BOOST_CHECK_EQUAL(1, i);
      }
      
      BOOST_AUTO_TEST_SUITE_END()
      
      BOOST_AUTO_TEST_SUITE(MyTestSuite_2)
      
      BOOST_AUTO_TEST_CASE(MyTest_2_1) {
          int i = 1;
          BOOST_CHECK_EQUAL(1, i);
      }
      
      BOOST_AUTO_TEST_SUITE_END()
      
      

      and run the test using the parameters

      --log_format=XML --log_level=test_suite --report_level=no --result_code=no --log_sink=xunit_test.xml

      The XML output is in the attached file xunit_test_good.xml and the xUnit plugin generated JUnit output is in the attached file junit_good.xml. Everything is as I would expect here and the table that is rendered on the Jenkins GUI has ExampleTestSuite at the top level with MyTestSuite_1 and MyTestSuite_2 nested below it.

      However, if I comment in the BOOST_TEST_MESSAGE line in the code, I get the message in the XML output as in the attached file xunit_test_bad.xml. This gets converted to the JUnit output in junit_test_bad.xml by the xUnit plugin. The nesting is now messed up in that ExampleTestSuite appears with a nested MyTestSuite_2 but ExampleTestSuite.MyTestSuite_1 appears alongside ExampleTestSuite.

      This is coming from the classname attribute in the generated JUnit output. Would it be possible to fix this so that test message output does not interfere with the generation of the classname attribute and hence the nesting of the test suites in the report? Alternatively, is there a workaround that I can apply to keep the log message but still have the expected nesting of the test suites?

       

        Attachments

        1. junit_test_bad.xml
          0.5 kB
        2. junit_test_good.xml
          0.3 kB
        3. xunit_test_bad.xml
          0.6 kB
        4. xunit_test_good.xml
          0.5 kB

          Activity

          Hide
          krandell Kim Randell added a comment -

          This comes from this line:

          https://github.com/jenkinsci/xunit-plugin/blob/5f017f9da41e987f3644c65f10658660519abfe5/src/main/resources/org/jenkinsci/plugins/xunit/types/boosttest-1.2-to-junit-4.xsl#L176

          Note that $elt/@file is only populated if the TestCase element has a first child with a file attribute (line 172). Therefore, if there is a message or assertion failure in the test, classname is the suite name concatenated with the filename (minus extension), otherwise it is just the suite name. It's unclear to me why the filename should be used in the classname in any case.

           

          Show
          krandell Kim Randell added a comment - This comes from this line: https://github.com/jenkinsci/xunit-plugin/blob/5f017f9da41e987f3644c65f10658660519abfe5/src/main/resources/org/jenkinsci/plugins/xunit/types/boosttest-1.2-to-junit-4.xsl#L176 Note that $elt/@file is only populated if the TestCase element has a first child with a file attribute (line 172). Therefore, if there is a message or assertion failure in the test, classname is the suite name concatenated with the filename (minus extension), otherwise it is just the suite name. It's unclear to me why the filename should be used in the classname in any case.  

            People

            Assignee:
            nfalco Nikolas Falco
            Reporter:
            fdfrancisduffy Francis Duffy
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated: