提高单元测试的xUnit插件在詹金斯不工作 [英] boost unit tests with xUnit Plugin in Jenkins do not work

查看:680
本文介绍了提高单元测试的xUnit插件在詹金斯不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不是一个C程序员,但我必须对我的詹金斯升压运行测试。现在,我已经安装了插件的xUnit詹金斯在

我添加了一个生成后的行动:发布的xUnit测试结果报告
然后,在此生成后步骤我补充说:BoostTest-1.x中(默认)

现在我有以下选项来设置:

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

我设置的选项是随机的,所以请帮助我,我什么都不懂,我没找到一些教程。

我还没有与升压单元测试工作,不与詹金斯的xUnit或者插件

任何一个能帮助我吗?

编辑:詹金斯说我:

 使[1]:离开目录`在/ var / lib中/詹金斯/工作区/ southernd_test
[的xUnit] [INFO] - 在开始录制。
[的xUnit] [INFO] - 处理BoostTest-1.x中(默认)
[的xUnit] [INFO] - [BoostTest-1.x中(默认)] - 无检测报告文件(S)被发现与模式'升压/ * XSL。相对于'在/ var / lib中/詹金斯/工作区/ southernd_test 对于测试框架BoostTest-1.x中(默认)。你进入相对正确的目录的模式?你生成BoostTest-1.x中(默认)的结果报告(S)?
[的xUnit] [错误] - 未找到度量BoostTest的解决模式'。升压/ * XSL的测试报告。配置错误?
[的xUnit] [INFO] - 设置构建状态失败
[的xUnit] [INFO] - 停止录音。
构建步骤发布的xUnit测试结果报告改为创建结果失败
表面处理:故障


解决方案

该错误是因为有一个由生成任何输出文件boost ::测试。测试脚本需要与正确的选项来调用:

  unit_test --report_level =详细--report_format = XML 2  - ; xunit.xml

不幸的是由升压::测试生成的XML输出​​文件是不正确的格式
(参见:<一href=\"http://stackoverflow.com/questions/2969131/anyone-have-an-xsl-to-convert-boost-test-xml-logs-to-a-$p$psentable-format\">SO转换的boost ::测试日志&放大器; <一href=\"http://jenkins.361315.n4.nabble.com/Can-anyone-help-with-Boost-C-unit-tests-and-the-xUnit-plugin-tt4194052.html#none\"相对=nofollow>升压帮助用户用的xUnit插件)

JUnit的插件预计XML测试输出是采用以下格式:

 &LT;&测试包GT;
  &LT;测试套件时间=0.0000时间戳=0.000错误=0失败=0的测试=13主机名=localhost的名字=my_test_suite&GT;
    &LT;测试用例ID =65536级=测试NAME =test_case_1时间=0.0000/&GT;
    &LT;测试用例ID =65537级=测试NAME =test_case_2时间=0.0000/&GT;
    &LT;测试用例ID =65538级=测试NAME =test_case_3时间=0.0000/&GT;
  &LT; /测试套件&GT;
&LT; /测试包&GT;

有几种方法来解决这个如:


  1. 通过转换XML输出​​的boost ::测试

  2. 直接定制的输出的boost ::测试,以便正确的格式就产生了。

我选择了选项2 - SS你是不是一个C / C ++程序员,你可以得到的测试套件你尝试运行遵循此办法的作者,按照如下步骤应该有助于让他们开始:


  1. 创建后处理的试运行结果的测试访问者。

  2. 创建,通过在其析构函数输出测试结果以正确的格式测试结果走一BOOST_GLOBAL_FIXTURE类。

  3. 实例化夹具类主要测试模块中。

即:

 结构JUnitVisitor:公​​众的boost :: unit_test :: test_tree_visitor
{
    无效的访问(提高:: unit_test :: test_case常量和放大器; TC)
    {
        //输出&LT;&测试用例GT; XML JUnit中的格式
    }    布尔test_suite_start(升压:: unit_test :: test_suite常量和放大器; TS)
    {
        //输出&LT; testuite&GT; XML JUnit中的格式
    }    无效test_suite_finish(升压:: unit_test :: test_suite常量和放大器; TS)
    {
        //输出&LT; / testuite&GT; XML JUnit中的格式
    }
};结构MyJUnitOpFixture
{
    MyJUnitOpFixture(){}    〜MyJUnitOpFixture()
    {
        //打开结果文件        ///输出&LT;&测试包GT;开始标记        //使用访问者行走测试结果树
        JUnitVisitor访问者(出);
        提高:: unit_test :: traverse_test_tree(
                 提高:: unit_test ::框架:: master_test_suite()
                 游客
                 );        ///输出&LT; /测试包&GT;结束标记    }
}

那么全球固定在主测试文件中加入实例:

  BOOST_GLOBAL_FIXTURE(MyJUnitOpFixture);

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

解决方案

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 ); 

这篇关于提高单元测试的xUnit插件在詹金斯不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆