Skip to content

robot.result.resultbuilder

ExecutionResult

ExecutionResult(*sources, **options)

Factory method to constructs :class:~.executionresult.Result objects.

:param sources: XML or JSON source(s) containing execution results. Can be specified as paths (pathlib.Path or str), opened file objects, or strings/bytes containing XML/JSON directly. :param options: Configuration options. Using merge=True causes multiple results to be combined so that tests in the latter results replace the ones in the original. Setting rpa either to True (RPA mode) or False (test automation) sets execution mode explicitly. By default, it is got from processed output files and conflicting modes cause an error. Other options are passed directly to the :class:ExecutionResultBuilder object used internally. :returns: :class:~.executionresult.Result instance.

A source is considered to be JSON in these cases: - It is a path with a .json suffix. - It is an open file that has a name attribute with a .json suffix. - It is string or bytes starting with { and ending with }.

This method should be imported by external code via the :mod:robot.api package. See the :mod:robot.result package for a usage example.

Source code in src/robot/result/resultbuilder.py
def ExecutionResult(*sources, **options):
    """Factory method to constructs :class:`~.executionresult.Result` objects.

    :param sources: XML or JSON source(s) containing execution results.
        Can be specified as paths (``pathlib.Path`` or ``str``), opened file
        objects, or strings/bytes containing XML/JSON directly.
    :param options: Configuration options.
        Using ``merge=True`` causes multiple results to be combined so that
        tests in the latter results replace the ones in the original.
        Setting ``rpa`` either to ``True`` (RPA mode) or ``False`` (test
        automation) sets execution mode explicitly. By default, it is got
        from processed output files and conflicting modes cause an error.
        Other options are passed directly to the
        :class:`ExecutionResultBuilder` object used internally.
    :returns: :class:`~.executionresult.Result` instance.

    A source is considered to be JSON in these cases:
    - It is a path with a ``.json`` suffix.
    - It is an open file that has a ``name`` attribute with a ``.json`` suffix.
    - It is string or bytes starting with ``{`` and ending with ``}``.

    This method should be imported by external code via the :mod:`robot.api`
    package. See the :mod:`robot.result` package for a usage example.
    """
    if not sources:
        raise DataError('One or more data source needed.')
    if options.pop('merge', False):
        return _merge_results(sources[0], sources[1:], options)
    if len(sources) > 1:
        return _combine_results(sources, options)
    return _single_result(sources[0], options)

ExecutionResultBuilder

1
2
3
ExecutionResultBuilder(
    source, include_keywords=True, flattened_keywords=None
)

Builds :class:~.executionresult.Result objects based on XML output files.

Instead of using this builder directly, it is recommended to use the :func:ExecutionResult factory method.

:param source: Path to the XML output file to build :class:~.executionresult.Result objects from. :param include_keywords: Controls whether to include keywords and control structures like FOR and IF in the result or not. They are not needed when generating only a report. :param flattened_keywords: List of patterns controlling what keywords and control structures to flatten. See the documentation of the --flattenkeywords option for more details.

Source code in src/robot/result/resultbuilder.py
def __init__(self, source, include_keywords=True, flattened_keywords=None):
    """
    :param source: Path to the XML output file to build
        :class:`~.executionresult.Result` objects from.
    :param include_keywords: Controls whether to include keywords and control
        structures like FOR and IF in the result or not. They are not needed
        when generating only a report.
    :param flattened_keywords: List of patterns controlling what keywords
        and control structures to flatten. See the documentation of
        the ``--flattenkeywords`` option for more details.
    """
    self._source = source \
        if isinstance(source, ETSource) else ETSource(source)
    self._include_keywords = include_keywords
    self._flattened_keywords = flattened_keywords