Robot Framework Integrated Development Environment (RIDE)
executionresult.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 robotide.lib.robot.errors import DataError
17 from robotide.lib.robot.model import Statistics
18 
19 from .executionerrors import ExecutionErrors
20 from .model import TestSuite
21 
22 
23 
31 class Result():
32 
33  def __init__(self, source=None, root_suite=None, errors=None, rpa=None):
34  #: Path to the XML file where results are read from.
35  self.sourcesource = source
36  #: Hierarchical execution results as a
37  #: :class:`~.result.model.TestSuite` object.
38  self.suitesuite = root_suite or TestSuite()
39  #: Execution errors as an
40  #: :class:`~.executionerrors.ExecutionErrors` object.
41  self.errorserrors = errors or ExecutionErrors()
42  self.generated_by_robotgenerated_by_robot = True
43  self._status_rc_status_rc = True
44  self._stat_config_stat_config = {}
45  self.rparpa = rpa
46 
47  @property
48 
69  statistics = property
70 
71  def statistics(self):
72  return Statistics(self.suitesuite, rpa=self.rparpa, **self._stat_config_stat_config)
73 
74  @property
75 
80  return_code = property
81 
82  def return_code(self):
83  if self._status_rc_status_rc:
84  return min(self.suitesuite.statistics.critical.failed, 250)
85  return 0
86 
87 
97  def configure(self, status_rc=True, suite_config=None, stat_config=None):
98  if suite_config:
99  self.suitesuite.configure(**suite_config)
100  self._status_rc_status_rc = status_rc
101  self._stat_config_stat_config = stat_config or {}
102 
103 
108  def save(self, path=None):
109  from robotide.lib.robot.reporting.outputwriter import OutputWriter
110  self.visitvisit(OutputWriter(path or self.sourcesource, rpa=self.rparpa))
111 
112 
123  def visit(self, visitor):
124  visitor.visit_result(self)
125 
126 
128  if self.generated_by_robotgenerated_by_robot:
130 
131 
132  def set_execution_mode(self, other):
133  if other.rpa is None:
134  pass
135  elif self.rparpa is None:
136  self.rparpa = other.rpa
137  elif self.rparpa is not other.rpa:
138  this, that = ('task', 'test') if other.rpa else ('test', 'task')
139  raise DataError("Conflicting execution modes. File '%s' has %ss "
140  "but files parsed earlier have %ss. Use '--rpa' "
141  "or '--norpa' options to set the execution mode "
142  "explicitly." % (other.source, this, that))
143 
144 
145 
147 
148  def __init__(self, results=None):
149  Result.__init__(self)
150  for result in results or ():
151  self.add_resultadd_result(result)
152 
153  def add_result(self, other):
154  self.set_execution_modeset_execution_mode(other)
155  self.suitesuite.suites.append(other.suite)
156  self.errorserrors.add(other.errors)
Used when variable does not exist.
Definition: errors.py:67
Container for total, suite and tag statistics.
Definition: statistics.py:27
Represents errors occurred during the execution of tests.
Combined results of multiple test executions.
def visit(self, visitor)
An entry point to visit the whole result object.
def handle_suite_teardown_failures(self)
Internal usage only.
def set_execution_mode(self, other)
Set execution mode based on other result.
def save(self, path=None)
Save results as a new output XML file.
def configure(self, status_rc=True, suite_config=None, stat_config=None)
Configures the result object and objects it contains.
def __init__(self, source=None, root_suite=None, errors=None, rpa=None)
return_code
Return code (integer) of test execution.
Represents results of a single test suite.
Definition: model.py:181