Testng 监听器遵守 Apache Ant JUnit XML Schema

Testng listener to comply with Apache Ant JUnit XML Schema

作为 testng 自动化测试套件的一部分,我想自动将结果从 jenkins 推送到 testrail。我目前在我的詹金斯服务器上安装了这个插件:https://github.com/jenkinsci/testrail-plugin

自述文件指出输出必须符合 junit 架构:https://github.com/windyroad/JUnit-Schema/blob/master/JUnit.xsd

我参考了 How do I get one junit report from TestNG for all my test cases? 并添加了

 <listeners>
    <listener class-name="org.testng.reporters.JUnitXMLReporter"></listener>
</listeners>

致我的听众;但是,这似乎没有以正确的格式创建文件,因为这会导致 jenkins 失败并显示消息:

正在将结果上传到 TestRail。 将结果推送到 TestRail 时出错 发帖到 index.php?/api/v2/add_results_for_cases/236 返回错误!来自 TestRail 的响应是: {"error":"Field :results cannot be empty (one result is required)"} 构建步骤 'TestRail Plugin' 将构建标记为失败 已完成:失败

我想知道是否应该使用其他监听器。

感谢您的帮助。

我使用问题中共享的 xsd 文件创建了一个符合 xsd.

TestNG 记者

要使用这个reporter,请添加如下依赖

<dependency>
    <groupId>com.rationaleemotions</groupId>
    <artifactId>junitreport</artifactId>
    <version>1.0.0</version>
</dependency>

本报记者利用服务加载器的方式对自身进行连线。因此不需要通过 <listeners> 标记(或)@Listeners 注释显式添加。

详情可见here