Skip to content

statistics

Statistics

Container for total, suite and tag statistics.

Accepted parameters have the same semantics as the matching command line options.

Source code in src/robot/model/statistics.py
class Statistics:
    """Container for total, suite and tag statistics.

    Accepted parameters have the same semantics as the matching command line
    options.
    """
    def __init__(self, suite, suite_stat_level=-1, tag_stat_include=None,
                 tag_stat_exclude=None, tag_stat_combine=None, tag_doc=None,
                 tag_stat_link=None, rpa=False):
        total_builder = TotalStatisticsBuilder(rpa=rpa)
        suite_builder = SuiteStatisticsBuilder(suite_stat_level)
        tag_builder = TagStatisticsBuilder(tag_stat_include,
                                           tag_stat_exclude, tag_stat_combine,
                                           tag_doc, tag_stat_link)
        suite.visit(StatisticsBuilder(total_builder, suite_builder, tag_builder))
        self.total: TotalStatistics = total_builder.stats
        self.suite: SuiteStatistics = suite_builder.stats
        self.tags: TagStatistics = tag_builder.stats

    def to_dict(self):
        return {
            'total': self.total.stat.get_attributes(include_label=True),
            'suites': [s.get_attributes(include_label=True) for s in self.suite],
            'tags': [t.get_attributes(include_label=True) for t in self.tags],
        }

    def visit(self, visitor):
        visitor.visit_statistics(self)