MarketSquare / robotframeworkguides

A project to share guides and best practices for robot framework and its ecosystem
25 stars 48 forks source link

"Getting result statistics" example not working. #58

Closed gohierf closed 1 month ago

gohierf commented 3 months ago

Hello,

I just tried running the first example of Getting result statistics:

from robot.api import ExecutionResult
result = ExecutionResult('output.xml')
stats = result.statistics
print(f"Number of Failed Tests: {stats.failed}")
print(f"Total number of Tests: {stats.passed}")

And I get the following error: AttributeError: 'Statistics' object has no attribute 'failed'

It seems that the proper way to get these statistics are through the total attribute:

print(f"Total number of Failed Tests: {stats.total.failed}")
print(f"Total number of Passed Tests: {stats.total.passed}")
manykarim commented 1 month ago

You're absolutely right, thank you. It has been fixed.