Question

I am not a C programmer, but i have to run boost tests on my Jenkins. Now I have installed the xUnit plugin in Jenkins.

I added a post-build action : "Publish xUnit test result report" Then, in this post-build step I added : "BoostTest-1.x (default)"

Now I have the following options to set:

https://www.dropbox.com/s/wxcny55rz2bqk6r/boost_jenkins_options.png

The options I set are random, so please help me, I don't understand anything and I didn't find some tutorials.

I have not worked with boost unit test and not with the xUnit Jenkins plugin either.

Can any one help me?

edit: jenkins say me this:

make[1]: Leaving directory `/var/lib/jenkins/workspace/southernd_test'
[xUnit] [INFO] - Starting to record.
[xUnit] [INFO] - Processing BoostTest-1.x (default)
[xUnit] [INFO] - [BoostTest-1.x (default)] - No test report file(s) were found with the pattern 'boost/*.xsl' relative to '/var/lib/jenkins/workspace/southernd_test' for the testing framework 'BoostTest-1.x (default)'.  Did you enter a pattern relative to the correct directory?  Did you generate the result report(s) for 'BoostTest-1.x (default)'?
[xUnit] [ERROR] - No test reports found for the metric 'BoostTest' with the resolved pattern 'boost/*.xsl'. Configuration error?.
[xUnit] [INFO] - Setting the build status to FAILURE
[xUnit] [INFO] - Stopping recording.
Build step 'Publish xUnit test result report' changed build result to FAILURE
Finished: FAILURE
Was it helpful?

Solution

The error is is because there is no output file generated by boost::test. The test script need to be invoked with the correct options:

unit_test --report_level=detailed --report_format=xml 2> xunit.xml

Unfortunately the XML output file produced by boost::test is not in the correct format (see: SO Converting boost::test logs & Boost Users Help with XUnit plugin )

The JUnit plugin expects XML test output to be in the following format:

<testsuites>
  <testsuite time="0.0000" timestamp="0.000" errors="0" failures="0" tests="13" hostname="localhost" name="my_test_suite">
    <testcase id="65536" class="test" name="test_case_1" time="0.0000" />
    <testcase id="65537" class="test" name="test_case_2" time="0.0000" />
    <testcase id="65538" class="test" name="test_case_3" time="0.0000" />
  </testsuite>
</testsuites>

There are a couple of ways to resolve this such as:

  1. Converting the XML output by boost::test
  2. Directly customising the output of boost::test so that the correct format is produced.

I opted for option 2 - ss you are not a 'C/C++' programmer you could get the author of the test suites you are trying to run to follow this approach, the steps below should help get them started:

  1. Create a test visitor for post processing the results of the test run.
  2. Create a BOOST_GLOBAL_FIXTURE class that walks through the test results in its destructor to output the test results in the correct format.
  3. Instantiate the fixture class in the main test module.

i.e.:

struct JUnitVisitor : public boost::unit_test::test_tree_visitor
{
    void visit( boost::unit_test::test_case const& tc )
    {
        // output <testcase> xml in JUnit format
    }

    bool test_suite_start( boost::unit_test::test_suite const& ts )
    {
        // output <testuite> xml in JUnit format
    }

    void test_suite_finish( boost::unit_test::test_suite const& ts )
    {
        // output </testuite> xml in JUnit format
    }
};

struct MyJUnitOpFixture
{
    MyJUnitOpFixture() {}

    ~MyJUnitOpFixture()
    {
        // open results file

        /// output <testsuites> start tag

        // use a visitor to walk the test results tree       
        JUnitVisitor visitor ( out );
        boost::unit_test::traverse_test_tree(
                 boost::unit_test::framework::master_test_suite(),
                 visitor
                 );

        /// output </testsuites> end tag

    }
}

Then the global fixture is instantiated in the main test file by adding:

BOOST_GLOBAL_FIXTURE( MyJUnitOpFixture ); 

OTHER TIPS

In my case xUnit does not like format of Boost Test's "--report_format=XML" but it DOES take "--log_format=XML --log_sink=test.xml"

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top