I have quite a complicated setup and the one use case that we have is that when all the tests have completed, as a last step, I should list all the failed test case names.
This data will then be written to a 3rd party logger via API. I already post data to said logger but struggling to get the list of failed test cases.
What I do have is a python script that does get all the names as a list but I am unsure how to get that data to robot framework so that it can be used in the REST call. (Json payload.)
Working script:
robotAPI.py
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('assets/results/output.xml')
result.visit(visitor)
for x in visitor.failed:
print(x)
Any help at this stage will be welcomed.