哈德逊,C++ 和单元测试++
有没有人使用 Hudson 作为 C++ 项目的持续集成服务器,使用 UnitTest++ 作为测试库?
你具体是怎么设置的?
我知道之前有几个关于持续集成的问题,但我希望这个问题的范围能缩小一些。
编辑:我会澄清一下我正在寻找的内容。 当单元测试失败时,我已经将构建设置为失败。 我正在寻找 Hudson 的 JUnit 支持之类的东西。 UnitTest++ 可以创建 XML 报告(请参阅此处)。 那么,也许如果有人知道如何将这些报告转换为 JUnit 兼容,Hudson 就会知道如何消化它?
Has anyone used Hudson as a Continuous-Integration server for a C++ project using UnitTest++ as a testing library?
How exactly did you set it up?
I know there have been several questions on Continuous Integration before, but I hope this one has a narrower scope.
EDIT: I'll clarify a bit on what I'm looking for. I already have the build set to fail when the Unit-Tests fail. I'm looking for something like Hudson's JUnit support. UnitTest++ can create XML reports (See here). So, perhaps if someone knows how to translate these reports to be JUnit compatible, Hudson will know how to eat it up?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
我们在我的办公室一直在使用类似的方法,只是使用 cxxtest 而不是 UnitTest++,现在我们正在迁移到 google 极其优越的(恕我直言)gtest 框架。
对于 cxxtest,我们做了类似于 Patrick J. 建议的事情,这基本上是添加一个构建步骤,该步骤将通过 ant 运行测试套件程序,并在任何测试失败时导致构建失败。 这种方法的缺点是,当构建由于测试结果而失败时,您必须通过控制台输出来找出问题所在。 如果您的测试框架可以输出与 junit 兼容的 XML,您还可以释放 hudson 可以生成的漂亮图表。
切换到 gtest 的激励因素之一是它确实生成 junit XML,因此理论上,hudson 可以解析测试结果并以更明智的方式发布它们。 不管怎样,它看起来不像 UnitTest++ 生成这样的东西(如果我错了,请纠正我),所以这可能是一个没有实际意义的点,但至少将它集成到你的构建过程中将确保测试在构建。
We've been using a similar approach at my office, except using cxxtest instead of UnitTest++, and now we're in the process to migrating to google's vastly superior (imho) gtest framework.
With cxxtest, we did something similar to what Patrick J. suggested, which was to basically add a build step which would run the test suite program via ant and cause the build to fail if any tests fail. The disadvantage of this approach is when the build fails due to a test result, then you have to go hunting through the console output to figure out what went wrong. Also you loose the nifty charts which hudson can generate if your test framework can output junit-compatible XML.
One of the motivating factors to switch to gtest is that it does generate junit XML, so in theory, hudson can parse the test results and publish them in a more sensible manner. Anyways, it doesn't look like UnitTest++ generates anything like this (please correct me if I'm wrong), so it might be a moot point, but at least integrating it into your build process will make sure that the tests get run during builds.
我们正在我的工作场所积极这样做。
目前,我们使用自由式软件项目来:
main()
返回,因此被视为构建错误我还测试了使用UnitTest++ 中包含 XmlTestReporter,用于生成输出文件。 xUnit 插件 本身支持此输出,以及您可以的任何其他输出转换,尽管我必须更改 0.1.3 版本中附带的 XSL 文件才能获取测试历史记录中记录的持续时间。
关于我们的集成,我们希望改进很多方面; 构建日志又长又难解析,没有着色或突出显示等,但到目前为止它仍然对我们有益。
We are actively doing this at my workplace.
Currently, we use a free-style software project to:
main()
, thus treated as build errorsI have also tested a configuration that uses the XmlTestReporter included with UnitTest++ to generate output files. The xUnit plugin natively supports this output, along with any other output you can convert, although I had to change the XSL file that came with it in version 0.1.3 to get durations recorded in the test history.
There are a lot of things we would like to improve about our integration; the build logs are long and hard to parse with no coloring or highlighting, etc., but so far it has still been beneficial to us.
我检查了 xUnit 插件,正如 Patrick Johnmeyer 在接受的答案中建议的那样。 为了完整起见,这里是驱动程序代码:
在Hudson配置中,选中“发布测试工具结果报告”并将其指向
“file.xml”
I checked the xUnit plugin, as Patrick Johnmeyer suggested in the accepted answer. For completeness sakes, here is the driver code:
In Hudson configuration, check "Publish testing tools result report" and point it to
"file.xml"
Hudson 现在有一个 CppUnit 插件 可以解决这个问题。
Hudson now has a CppUnit plugin that may do the trick.
早在我开始使用 Hudson 之前,我就参与了一个 C++ 项目,其中我们使用了 cpp-unit-lite 和 CruiseControl。
我们更改了 Cpp-unit-lite 以生成类似 XML 报告文件的 JUnit,而 CruiseControl 则选取了 XML 报告文件。
您可以对 UnitTest++ 执行相同的操作,Hudson 将拾取报告文件。
然而,这似乎需要很多工作。 看看 Hudson 的绘图插件。 您可以让脚本从 UnitTest++ 输出中提取失败/通过测试的数量,并使用绘图插件绘制每个构建的通过/失败测试的简单图表。
不如内置的单元测试报告那么好,但您可以快速开始工作。
Long before I started to use Hudson, I worked on a C++ project where we used cpp-unit-lite and CruiseControl
We altered Cpp-unit-lite to generate JUnit like XML report files and CruiseControl picked up the XML report files.
You can do the same for UnitTest++ and Hudson will pickup the report files.
However, that seems like a lot of work. Have a look at the plot plugin for Hudson. You can have a script extract the number of failing/passing tests from the UnitTest++ output and use the plot plugin to draw a simple graph of passing/failing tests per build.
Not as nice as the in-built unit test report but something you can get working quickly.
我将 hudson 与 CppUnit 和 xml 输出一起使用。 xml 由 xslt 转换为 JUnit 输出,例如。
CppUnit 站点提供了一个 xslt,可将 CppUnit 输出转换为 JUnit 输出。 我对它进行了一些修改,以获得更多详细信息,例如:
您可以转换您的 xml 输出以获得以下内容:
如果成功:只需删除子标签
问候
I use hudson with CppUnit and xml output. The xml are translated by xslt to a JUnit output like.
CppUnit site provides an xslt that convert CppUnit output to JUnit output. I have hacked it a bit in order to get mre details like :
you may transform your xml output to get the following:
In case of success : just remove the sub tag
Regards