Python Jenkins从XML文件报告

Python Jenkins从XML文件报告,python,xml,jenkins,Python,Xml,Jenkins,这是我的第一篇帖子,很抱歉,如果有一个问题的答案,我已经得到了,但我认为它是非常具体的 我的团队成员创建了一个非常简单的测试环境,用于测试cpp项目中的功能,并将启动的测试用例报告生成txt文件,如下所示: 0测试用例1通过 1个测试用例2通过 2个测试用例2失败 等等 我的任务是从这个txt中准备一个xml文件,并将其提交给Jenkins,以便通过测试运行生成漂亮的图表 目前,我尝试将这个txt解析为Python lxml库生成的JUnitXml文件 此txt中的Xml文件如下所示: 当我把

这是我的第一篇帖子,很抱歉,如果有一个问题的答案,我已经得到了,但我认为它是非常具体的

我的团队成员创建了一个非常简单的测试环境,用于测试cpp项目中的功能,并将启动的测试用例报告生成txt文件,如下所示:

0测试用例1通过
1个测试用例2通过
2个测试用例2失败
等等

我的任务是从这个txt中准备一个xml文件,并将其提交给Jenkins,以便通过测试运行生成漂亮的图表

目前,我尝试将这个txt解析为Python lxml库生成的JUnitXml文件

此txt中的Xml文件如下所示:

当我把它交给Jenkins时,它只生成运行的测试结果,在本例中,所有测试都已启动。 我的XML文件缺少什么? 我们的测试环境是否需要任何外部库来生成更好的xml,其中包含有关通过的、失败的测试用例的信息


干杯。

根据您的报告,您应该在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>


您可以找到

的描述(模式)。根据您的报告,您应该在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>


您可以发现

的描述(模式)听起来像您的队友刚刚启动了他们自己的单元测试框架。为什么不使用现有的、成熟的单元测试框架,而不是重新发明轮子呢?我的队友们有很好的经验,将GoogleTestFrand集成到一个现有的C++项目中。使用xUnit插件将其集成到Jenkins中也很容易。当然,在我开始这个项目之前,他们尝试使用现有的测试框架,可能是Boost测试库,它将他们现有的代码转换为它自己的或类似于smth的代码,所以他们离开了它,GoogleTest也有一个主题,但负责获取相关信息的人被转移到了另一个项目。听起来你的团队成员刚刚启动了他们自己的单元测试框架。为什么不使用现有的、成熟的单元测试框架,而不是重新发明轮子呢?我的队友们有很好的经验,将GoogleTestFrand集成到一个现有的C++项目中。使用xUnit插件将其集成到Jenkins中也很容易。当然,在我开始这个项目之前,他们尝试使用现有的测试框架,可能是Boost测试库,它将他们现有的代码转换为它自己的或类似于smth的代码,所以他们离开了它,Google Test也有一个主题,但负责获取相关信息的人被转移到了另一个项目。