2017-09-15 75 views
1

这是我的第一篇文章,很抱歉,如果存在问题的答案我有,但我认为这是非常具体的。詹金斯从XML文件报告

我的队友创造了该测试在CPP项目的功能非常简单的测试环境和它产生的推出测试用例的报告为txt文件,该文件是这样的:

0 testcase1 PASS
1 testcase2 PASS
2个testcase2失败

我的任务是从这个txt准备一个xml文件,并把它放到Jenkins生成测试运行的漂亮图表。

目前我尝试将此txt解析为由Python lxml库生成的JUnitXml文件。从这个TXT

XML文件如下所示: xml

当我把它詹金斯它产生我只是结果这是运行测试,在这种情况下,所有测试启动。 我在XML文件中缺少什么? 我是否需要任何外部库到我们的测试环境,这将产生更好的XML与关于通过,失败的测试案例的信息?

干杯。

+1

描述(架构)听起来像是你的队友刚刚开始自己​​的单元测试框架。为什么不使用现有的,成熟的单元测试框架而不是重新发明轮子?我的队友们将GoogleTest框架集成到现有的C++项目中有很棒的经验。使用xUnit插件将它集成到Jenkins中也很容易。 –

+0

当然,在我来到这个项目之前,他们试图使用现有的测试框架,它可能是Boost Test Library,它将现有的代码转换为自己的代码,所以他们离开了它,还有一个GoogleTest的主题,但是一个负责获得有关信息的人被转移到另一个项目中。 – asdator1213

回答

0

这里是你应该根据自己的报告中的XML报告查找:

<testsuite skip="0" failures="1" errors="0" tests="3" name="Name of the tests"> 
    <testcase name="testcase1" classname="This is a name to identify in which class is located the test"/> 
    <testcase name="testcase2" classname="This is another(or not) name to identify in which class is located the test"/> 
    <testcase name="testcase3" classname="This is another(or not) name to identify in which class is located the test"> 
     <failure message="Any message of the failing output" type="You can specify the kind of error"> 
      <![CDATA[ "Here you can put a complete stacktrace or 
any log message associated with your failure" ]]> 
     </failure> 
    </testcase> 
</testsuite> 

你可以找到的JUnit XML format here

+1

看起来像它的作品! ;) 谢谢 – asdator1213