Python 我可以使用robot.api获取失败的测试用例名称吗?
我正在尝试使用python中的robot api从output.xml获取失败的测试用例名称,我能够使用下面的代码获取失败/通过测试的计数,但找不到任何方法来获取测试用例名称。 提前谢谢Python 我可以使用robot.api获取失败的测试用例名称吗?,python,robotframework,Python,Robotframework,我正在尝试使用python中的robot api从output.xml获取失败的测试用例名称,我能够使用下面的代码获取失败/通过测试的计数,但找不到任何方法来获取测试用例名称。 提前谢谢 from robot.api import ExecutionResult result = ExecutionResult('output.xml') result.configure(stat_config={'suite_stat_level': 2,
from robot.api import ExecutionResult
result = ExecutionResult('output.xml')
result.configure(stat_config={'suite_stat_level': 2,
'tag_stat_combine': 'tagANDanother'})
stats = result.statistics
print stats.total.critical.failed
print stats.total.critical.passed
print stats.tags.combined[0].total
您可能需要
ResultVisitor
。这样做应该会有所帮助:
from robot.api import ExecutionResult, ResultVisitor
class Visitor(ResultVisitor):
def __init__(self):
self.failed = []
def end_test(self, test):
if test.status == "FAIL":
self.failed.append(test)
visitor = Visitor()
result = ExecutionResult('output.xml')
result.visit(visitor)
print(visitor.failed)
文档可在Show content of output.xml上找到