解析 Robot Framework 的输出 xml [英] Parse Robot Framework's output xml

查看:99
本文介绍了解析 Robot Framework 的输出 xml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Robot 框架会输出一个 XML 输出,然后用于构建 HTML 报告(使用 rebot)、重新运行失败等.

Robot framework spits out an output XML which is then used to build the HTML reports (with rebot), re-run failures, etc.

我需要解析这个文件来生成其他报告,特别是,我需要解析测试用例的文档以获取正则表达式,获取测试用例结果,然后构建报告(这是为了与遗留系统集成).

I need to parse this file to generate other reports, in particular, I need to parse the test case's documentation for a regex, get the test case result and then build a report (this is for integration with a legacy system).

Robot Framework 是否提供了轻松解析输出 XML 文件的功能,或者我们只使用标准的 XML 解析库?

Does Robot Framework provide functionality to easily parse the output XML file or we just use standard XML parsing libraries?

推荐答案

好的,找到 3 个可行的响应:

Ok, found 3 viable responses:

  1. 使用 DbBot 并查询创建的数据库.
  2. 直接解析 XML 文件.使用 xml.etree.ElementTree 非常简单.
  3. 使用 Robot Framework 的 ExecutionResult,其中遵循 Visitor 模式(在 ResultVisitor,我们必须对其进行扩展)并允许您在 visit_test 方法中执行您需要的操作.
  1. Use DbBot and query the DB created.
  2. Parse the XML file directly. Using xml.etree.ElementTree is pretty simple.
  3. Use Robot Framework's ExecutionResult, which follows the Visitor pattern (in ResultVisitor, which we have to extend) and that allows you to do what you need in the visit_test method.

最终选择了选项 3,因为它是 Robot Framework 的一部分,如果 XML 文件的格式发生变化,则不太可能破坏(或更容易修复).

Ended up with going with option 3 as that is part of Robot Framework and less likely to break (or easier to fix) if the format of the XML file changes.

这篇关于解析 Robot Framework 的输出 xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆