Skip to content

robot.reporting.resultwriter

ResultWriter

ResultWriter(*sources)

A class to create log, report, output XML and xUnit files.

:param sources: Either one :class:~robot.result.executionresult.Result object, or one or more paths to existing output XML files.

By default writes report.html and log.html, but no output XML or xUnit files. Custom file names can be given and results disabled or enabled using settings or options passed to the :meth:write_results method. The latter is typically more convenient::

1
2
writer = ResultWriter(result)
writer.write_results(report='custom.html', log=None, xunit='xunit.xml')
Source code in src/robot/reporting/resultwriter.py
def __init__(self, *sources):
    self._sources = sources

write_results

write_results(settings=None, **options)

Writes results based on the given settings or options.

:param settings: :class:~robot.conf.settings.RebotSettings object to configure result writing. :param options: Used to construct new :class:~robot.conf.settings.RebotSettings object if settings are not given.

Source code in src/robot/reporting/resultwriter.py
def write_results(self, settings=None, **options):
    """Writes results based on the given ``settings``  or ``options``.

    :param settings: :class:`~robot.conf.settings.RebotSettings` object
        to configure result writing.
    :param options: Used to construct new
        :class:`~robot.conf.settings.RebotSettings` object if ``settings``
        are not given.
    """
    settings = settings or RebotSettings(options)
    results = Results(settings, *self._sources)
    if settings.output:
        self._write_output(results.result, settings.output, settings.legacy_output)
    if settings.xunit:
        self._write_xunit(results.result, settings.xunit)
    if settings.log:
        config = dict(settings.log_config,
                      minLevel=results.js_result.min_level)
        self._write_log(results.js_result, settings.log, config)
    if settings.report:
        results.js_result.remove_data_not_needed_in_report()
        self._write_report(results.js_result, settings.report,
                           settings.report_config)
    return results.return_code