简体   繁体   English

Jenkins从XML文件报告

[英]Jenkins reporting from XML file

this is my first post so sorry if there exists answer for a problem I 've got, but I think it is very specific. 这是我的第一篇文章,非常抱歉,如果对我遇到的问题有答案,但我认为这是非常具体的。

My teammates created a very simple testing environment which tests functions in cpp project and it produces report of launched testcases to txt file which looks like this: 我的队友创建了一个非常简单的测试环境,该环境可以测试cpp项目中的功能,并且可以将已启动测试用例的报告生成为txt文件,如下所示:

0 testcase1 PASS 0个测试用例1个通过
1 testcase2 PASS 1个测试用例2个PASS
2 testcase2 FAIL 2个测试用例2个失败
and so on 等等

My task is to prepare an xml file from this txt and put it to Jenkins to generate pretty charts with test run. 我的任务是从该txt准备一个xml文件,并将其放入Jenkins,以通过测试运行生成漂亮的图表。

Currently I try to parse this txt to JUnitXml file generated by Python lxml library. 目前,我尝试将此txt解析为Python lxml库生成的JUnitXml文件。

Xml file from this txt looks like this: xml 来自该txt的XML文件如下所示: xml

When I put it to Jenkins it produces me only result of tests which were run, in this case all tests were launched. 当我将其放在Jenkins上时,它仅生成运行测试的结果,在这种情况下,所有测试均已启动。 What am I missing in my XML file? 我的XML文件中缺少什么? Do I need any external library to our test environment which would produce better xml with information about passed, failed testcases? 我是否需要在我们的测试环境中使用任何外部库,这些库会生成更好的xml以及有关已通过失败的测试用例的信息?

Cheers. 干杯。

Here is what you should find in your xml report according to your report : 这是您应该根据您的报告在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>

You can find the description (Schema) of the JUnit XML format here 您可以在此处找到JUnit XML格式的描述(架构)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM