猿问

Hudson支持的JUnit XML格式规范是什么?

我将Hudson作为持续集成服务器,并且我想使用选项“发布JUnit测试结果报告”。但是我不使用xUnit工具进行测试,相反,我拥有运行测试并以简单格式返回结果的shell脚本。我正在考虑制作一个脚本,将这些结果转换为JUnit格式。所以我很有趣JUnit文件的外观如何?



手掌心
浏览 610回答 3
3回答

江户川乱折腾

几个月前,我做了类似的事情,结果证明这种简单的格式足以让哈德森接受它作为测试协议:<testsuite tests="3">&nbsp; &nbsp; <testcase classname="foo1" name="ASuccessfulTest"/>&nbsp; &nbsp; <testcase classname="foo2" name="AnotherSuccessfulTest"/>&nbsp; &nbsp; <testcase classname="foo3" name="AFailingTest">&nbsp; &nbsp; &nbsp; &nbsp; <failure type="NotEnoughFoo"> details about failure </failure>&nbsp; &nbsp; </testcase></testsuite>这个问题的答案有更多详细信息:规格。用于JUnit XML输出

慕森卡

我只是抓住了其他人链接到的junit-4.xsd,并使用了一个名为XMLSpear的工具,通过以下所示的选项将架构转换为空白XML文件。这是(稍作清理)的结果:<?xml version="1.0" encoding="UTF-8"?><testsuites disabled="" errors="" failures="" name="" tests="" time="">&nbsp; &nbsp; <testsuite disabled="" errors="" failures="" hostname="" id=""&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;name="" package="" skipped="" tests="" time="" timestamp="">&nbsp; &nbsp; &nbsp; &nbsp; <properties>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <property name="" value=""/>&nbsp; &nbsp; &nbsp; &nbsp; </properties>&nbsp; &nbsp; &nbsp; &nbsp; <testcase assertions="" classname="" name="" status="" time="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <skipped/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <error message="" type=""/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <failure message="" type=""/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <system-out/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <system-err/>&nbsp; &nbsp; &nbsp; &nbsp; </testcase>&nbsp; &nbsp; &nbsp; &nbsp; <system-out/>&nbsp; &nbsp; &nbsp; &nbsp; <system-err/>&nbsp; &nbsp; </testsuite></testsuites>其中一些项目可能会多次出现:testsuites因为XML是这样工作的,所以只能有一个元素,但是testsuite元素内可以有多个元素testsuites。每个properties元素可以有多个property子代。每个testsuite元素可以有多个testcase子代。每一个testcase元素可以有多个error,failure,system-out,或system-err孩子。
随时随地看视频慕课网APP
我要回答