无法获取hudson来解析JUnit测试输出XML [英] Unable to get hudson to parse JUnit test output XML

查看:224
本文介绍了无法获取hudson来解析JUnit测试输出XML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

EDIT :此问题已由google在gtest 1.4.0中修复; 查看原始错误报告了解详情。

EDIT: This issue has been fixed by google in gtest 1.4.0; see the original bug report for more information.

我最近切换到gtest的C ++测试框架,我目前无法使用的一个伟大的功能是生成JUnit风格的XML测试报告的能力,

I've recently switched to gtest for my C++ testing framework, and one great feature of it which I am presently unable to use is the ability to generate JUnit-style XML test reports, which could then be read in by our hudson build server.

gtest测试套件生成的XML输出看起来都是合法的:

The XML output generated by the gtest test suite all looks legit:

<?xml version="1.0" encoding="UTF-8"?>
<testsuite tests="370" failures="0" disabled="0" errors="0" time="45.61" name="AllTests">
    <testsuite name="application" tests="7" failures="0" disabled="0" errors="0" time="8.953">
        <testcase name="zero_tasks_on_bootup" status="run" time="0" classname="application" />
...etc.
    </testsuite>
</testsuite>

我也试过向我的ant构建脚本添加一个JUnitReport任务,它工作正常,并生成XML如此:

I've also tried adding a JUnitReport task to my ant build script, which works fine, and generates XML like so:

<?xml version="1.0" encoding="UTF-8"?>
<testsuite tests="370" failures="0" disabled="0" errors="0" time="45.61" name="AllTests">
    <testsuite name="application" tests="7" failures="0" disabled="0" errors="0" time="8.953">
        <testcase name="zero_tasks_on_bootup" status="run" time="0" classname="application" />
    ...etc.
    </testsuite>
 </testsuite>

问题是,每当我告诉ant发布JUnit测试结果,原始测试结果XML或在ant JUnitReport任务中生成的编译结果,hudson总是抱怨在那里没有找到测试结果。

The problem is, whenever I tell ant to publish the JUnit test results, and then point it to either the raw test result XML, or the compiled result generated in the ant JUnitReport task, hudson always complains about finding no test results there.

我不是一个java人,所以我不能告诉这里发生了什么,我找不到一个示例如何JUnit XML应该是看起来像。

I'm not a java guy, so I can't tell what's going on here, and I can't find an example of how the JUnit XML ought to look like. Can someone help to point me in the right direction?

推荐答案

编辑:Google测试已修正此问题问题,它包含在gtest 1.4.0版本中。 查看原始错误报告了解详情。

Edit: Google test has fixed this issue, which is included in the gtest 1.4.0 release. See the original bug report for more info.

Bah!我终于找到了这个问题的原因 - 这是因为gtest为所有测试结果生成一个巨大的XML文件,而且Hudson希望每个类都有一个XML测试报告。我写了 perl脚本作为此问题的解决方法。要使用它,你将在你的ant xml脚本中创建一个目标,看起来像这样:

Bah! I've finally found the cause of this problem -- it's because gtest produces one giant XML file for all test results, and hudson expects one XML test report per class. I've written a perl script as a workaround for this issue. To use it, you would make a target in your ant xml script which looks something like this:

<target name="runtests">
  <exec executable="wherever/${ant.project.name}Test" failonerror="false" dir="tests">
    <arg value="--gtest_output=xml:${build.dir}\reports\${ant.project.name}.xml"/>
  </exec>
  <!-- Workaround for broken gtest output -->
  <mkdir dir="${build.dir}/reports/output"/>
  <exec executable="perl" failonerror="false" dir="tests">
  <arg value="gtest-hudson.pl"/>
    <arg value="${build.dir}/reports/${ant.project.name}.xml"/>
    <arg value="${build.dir}/reports/output"/>
  </exec>
</target>

由于某种原因,gtest也不喜欢从蚂蚁传递给它的错误样式,所以我使我的exec只为windows,因为我的哈德逊运行在Windows服务器。显然,更改为'/'。

For some reason, gtest also doesn't like the wrong style of slashes being passed to it from ant, so I made my exec for windows only, as my hudson is running on a windows server. Change to '/' for unix, obviously.

我还有在gtest页面上提交了问题,还有一个在 hudson的问题跟踪器,所以希望两个团队中的一个会接手这个问题,因为我没有足够的时间跳入和制作一个补丁如果这不是在不久的将来固定,我可能只是需要。 ;)

I've also filed an issue for this on the gtest page, and also one on hudson's issue tracker, so hopefully one of the two teams will pick up on the issue, as I don't have enough time to jump in and make a patch myself.... though if this doesn't get fixed in the near future, I might just have to. ;)

这篇关于无法获取hudson来解析JUnit测试输出XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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