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

xUnit Plugin problem with Boost test XML output that contains messages

XMLWordPrintable

    • 3.1.2

      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?

       

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

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

              Created:
              Updated:
              Resolved: