Robot Framework
statistics.py
Go to the documentation of this file.
1 # Copyright 2008-2015 Nokia Networks
2 # Copyright 2016- Robot Framework Foundation
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 
16 from .totalstatistics import TotalStatisticsBuilder
17 from .suitestatistics import SuiteStatisticsBuilder
18 from .tagstatistics import TagStatisticsBuilder
19 from .visitor import SuiteVisitor
20 
21 
22 
27 class Statistics:
28  def __init__(self, suite, suite_stat_level=-1, tag_stat_include=None,
29  tag_stat_exclude=None, tag_stat_combine=None, tag_doc=None,
30  tag_stat_link=None, rpa=False):
31  total_builder = TotalStatisticsBuilder(rpa=rpa)
32  suite_builder = SuiteStatisticsBuilder(suite_stat_level)
33  tag_builder = TagStatisticsBuilder(tag_stat_include,
34  tag_stat_exclude, tag_stat_combine,
35  tag_doc, tag_stat_link)
36  suite.visit(StatisticsBuilder(total_builder, suite_builder, tag_builder))
37  #: Instance of :class:`~robot.model.totalstatistics.TotalStatistics`.
38  self.totaltotal = total_builder.stats
39  #: Instance of :class:`~robot.model.suitestatistics.SuiteStatistics`.
40  self.suitesuite = suite_builder.stats
41  #: Instance of :class:`~robot.model.tagstatistics.TagStatistics`.
42  self.tagstags = tag_builder.stats
43 
44  def visit(self, visitor):
45  visitor.visit_statistics(self)
46 
47 
49 
50  def __init__(self, total_builder, suite_builder, tag_builder):
51  self._total_builder_total_builder = total_builder
52  self._suite_builder_suite_builder = suite_builder
53  self._tag_builder_tag_builder = tag_builder
54 
55  def start_suite(self, suite):
56  self._suite_builder_suite_builder.start_suite(suite)
57 
58  def end_suite(self, suite):
59  self._suite_builder_suite_builder.end_suite()
60 
61  def visit_test(self, test):
62  self._total_builder_total_builder.add_test(test)
63  self._suite_builder_suite_builder.add_test(test)
64  self._tag_builder_tag_builder.add_test(test)
65 
66  def visit_keyword(self, kw):
67  pass
def __init__(self, total_builder, suite_builder, tag_builder)
Definition: statistics.py:50
def visit_test(self, test)
Implements traversing through tests.
Definition: statistics.py:61
def end_suite(self, suite)
Called when a suite ends.
Definition: statistics.py:58
def visit_keyword(self, kw)
Implements traversing through keywords.
Definition: statistics.py:66
def start_suite(self, suite)
Called when a suite starts.
Definition: statistics.py:55
Container for total, suite and tag statistics.
Definition: statistics.py:27
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)
Definition: statistics.py:30
Interface to ease traversing through a test suite structure.
Definition: visitor.py:85