Robot Framework Integrated Development Environment (RIDE)
totalstatistics.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 .stats import TotalStat
17 from .visitor import SuiteVisitor
18 
19 
20 
22 
23  def __init__(self, rpa=False):
24  #: Instance of :class:`~robot.model.stats.TotalStat` for critical tests.
25  test_or_task = 'Tests' if not rpa else 'Tasks'
26  self.criticalcritical = TotalStat('Critical ' + test_or_task)
27  #: Instance of :class:`~robot.model.stats.TotalStat` for all the tests.
28  self.allall = TotalStat('All ' + test_or_task)
29  self._rpa_rpa = rpa
30 
31  def visit(self, visitor):
32  visitor.visit_total_statistics(self)
33 
34  def __iter__(self):
35  return iter([self.criticalcritical, self.allall])
36 
37  @property
38 
45  message = property
46 
47  def message(self):
48  test_or_task = 'test' if not self._rpa_rpa else 'task'
49  ctotal, cend, cpass, cfail = self._get_counts_get_counts(self.criticalcritical)
50  atotal, aend, apass, afail = self._get_counts_get_counts(self.allall)
51  return ('%d critical %s%s, %d passed, %d failed\n'
52  '%d %s%s total, %d passed, %d failed'
53  % (ctotal, test_or_task, cend, cpass, cfail,
54  atotal, test_or_task, aend, apass, afail))
55 
56  def _get_counts(self, stat):
57  ending = 's' if stat.total != 1 else ''
58  return stat.total, ending, stat.passed, stat.failed
59 
60 
62 
63  def __init__(self, suite=None, rpa=False):
64  self.statsstats = TotalStatistics(rpa)
65  if suite:
66  suite.visit(self)
67 
68  def add_test(self, test):
69  self.statsstats.all.add_test(test)
70  if test.critical:
71  self.statsstats.critical.add_test(test)
72 
73  def visit_test(self, test):
74  self.add_testadd_test(test)
75 
76  def visit_keyword(self, kw):
77  pass
Stores statistic values for a test run.
Definition: stats.py:101
def visit_keyword(self, kw)
Implements traversing through the keyword and its child keywords.
def visit_test(self, test)
Implements traversing through the test and its keywords.
message
String representation of the statistics.
Interface to ease traversing through a test suite structure.
Definition: visitor.py:75