Skip to content

Instantly share code, notes, and snippets.

@adiralashiva8
Created January 28, 2019 16:08
Show Gist options
  • Save adiralashiva8/4b679df1af0aa8ce539d101c066575ee to your computer and use it in GitHub Desktop.
Save adiralashiva8/4b679df1af0aa8ce539d101c066575ee to your computer and use it in GitHub Desktop.
Robotframework: Get suite metrics like suite name, suite status, total tests in suite, suite duration by parsing output.xml using robot.result package (api)
from robot.api import ExecutionResult, ResultVisitor
class SuiteResults(ResultVisitor):
def start_suite(self, suite):
suite_test_list = suite.tests
if not suite_test_list:
pass
else:
stats = suite.statistics
print "Suite name:",suite
print "Suite status:",suite.status
print "Total tests in suite:",stats.all.total
print "Passed tests in suite:",stats.all.passed
print "Failed tests in suite:",stats.all.failed
print "Suite start time:",suite.starttime
print "Suite end time:",suite.endtime
print "Suite duration(s):",suite.elapsedtime/float(1000)
result = ExecutionResult("output.xml")
result.visit(SuiteResults())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment