Example #1
0
 def main(self, datasources, **options):
     settings = RobotSettings(options)
     LOGGER.register_console_logger(**settings.console_output_config)
     LOGGER.info('Settings:\n%s' % unic(settings))
     builder = TestSuiteBuilder(settings['SuiteNames'],
                                extension=settings.extension,
                                rpa=settings.rpa,
                                allow_empty_suite=settings.run_empty_suite)
     suite = builder.build(*datasources)
     settings.rpa = suite.rpa
     if settings.pre_run_modifiers:
         suite.visit(ModelModifier(settings.pre_run_modifiers,
                                   settings.run_empty_suite, LOGGER))
     suite.configure(**settings.suite_config)
     with pyloggingconf.robot_handler_enabled(settings.log_level):
         old_max_error_lines = text.MAX_ERROR_LINES
         text.MAX_ERROR_LINES = settings.max_error_lines
         try:
             result = suite.run(settings)
         finally:
             text.MAX_ERROR_LINES = old_max_error_lines
         LOGGER.info("Tests execution ended. Statistics:\n%s"
                     % result.suite.stat_message)
         if settings.log or settings.report or settings.xunit:
             writer = ResultWriter(settings.output if settings.log
                                   else result)
             writer.write_results(settings.get_rebot_settings())
     return result.return_code
 def main(self, datasources, **options):
     settings = RobotSettings(options)
     LOGGER.register_console_logger(**settings.console_output_config)
     if settings['Critical'] or settings['NonCritical']:
         LOGGER.warn("Command line options --critical and --noncritical have been "
                     "deprecated. Use --skiponfailure instead.")
     if settings['XUnitSkipNonCritical']:
         LOGGER.warn("Command line option --xunitskipnoncritical has been "
                     "deprecated and has no effect.")
     LOGGER.info('Settings:\n%s' % unic(settings))
     builder = TestSuiteBuilder(settings['SuiteNames'],
                                included_extensions=settings.extension,
                                rpa=settings.rpa,
                                allow_empty_suite=settings.run_empty_suite)
     suite = builder.build(*datasources)
     settings.rpa = suite.rpa
     if settings.pre_run_modifiers:
         suite.visit(ModelModifier(settings.pre_run_modifiers,
                                   settings.run_empty_suite, LOGGER))
     suite.configure(**settings.suite_config)
     with pyloggingconf.robot_handler_enabled(settings.log_level):
         old_max_error_lines = text.MAX_ERROR_LINES
         text.MAX_ERROR_LINES = settings.max_error_lines
         try:
             result = suite.run(settings)
         finally:
             text.MAX_ERROR_LINES = old_max_error_lines
         LOGGER.info("Tests execution ended. Statistics:\n%s"
                     % result.suite.stat_message)
         if settings.log or settings.report or settings.xunit:
             writer = ResultWriter(settings.output if settings.log
                                   else result)
             writer.write_results(settings.get_rebot_settings())
     return result.return_code
Example #3
0
 def main(self, datasources, **options):
     settings = RobotSettings(options)
     LOGGER.register_console_logger(**settings.console_output_config)
     LOGGER.info('Settings:\n%s' % unic(settings))
     builder = TestSuiteBuilder(settings['SuiteNames'],
                                extension=settings.extension,
                                rpa=settings.rpa)
     suite = builder.build(*datasources)
     settings.rpa = builder.rpa
     suite.configure(**settings.suite_config)
     if settings.pre_run_modifiers:
         suite.visit(ModelModifier(settings.pre_run_modifiers,
                                   settings.run_empty_suite, LOGGER))
     with pyloggingconf.robot_handler_enabled(settings.log_level):
         old_max_error_lines = text.MAX_ERROR_LINES
         text.MAX_ERROR_LINES = settings.max_error_lines
         try:
             result = suite.run(settings)
         finally:
             text.MAX_ERROR_LINES = old_max_error_lines
         LOGGER.info("Tests execution ended. Statistics:\n%s"
                     % result.suite.stat_message)
         if settings.log or settings.report or settings.xunit:
             writer = ResultWriter(settings.output if settings.log
                                   else result)
             writer.write_results(settings.get_rebot_settings())
     return result.return_code
Example #4
0
 def main(self, datasources, **options):
     settings = RobotSettings(options)
     LOGGER.register_console_logger(**settings.console_output_config)
     LOGGER.info('Settings:\n%s' % unic(settings))
     if settings['WarnOnSkipped'] is not None:
         LOGGER.error("Option '--warnonskippedfiles is deprecated and "
                      "has no effect.")
     builder = TestSuiteBuilder(settings['SuiteNames'],
                                extension=settings.extension,
                                rpa=settings.rpa)
     suite = builder.build(*datasources)
     settings.rpa = builder.rpa
     suite.configure(**settings.suite_config)
     if settings.pre_run_modifiers:
         suite.visit(
             ModelModifier(settings.pre_run_modifiers,
                           settings.run_empty_suite, LOGGER))
     with pyloggingconf.robot_handler_enabled(settings.log_level):
         result = suite.run(settings)
         LOGGER.info("Tests execution ended. Statistics:\n%s" %
                     result.suite.stat_message)
         if settings.log or settings.report or settings.xunit:
             writer = ResultWriter(
                 settings.output if settings.log else result)
             writer.write_results(settings.get_rebot_settings())
     return result.return_code
Example #5
0
def runner(datasources, **options):
    tests = _tests(datasources)
    settings = RobotSettings(options)
    rf_test_to_actual, suite = _build_rf_suite(datasources, settings, tests)
    LOGGER.register_console_logger(**settings.console_output_config)
    with pyloggingconf.robot_handler_enabled(settings.log_level):
        with STOP_SIGNAL_MONITOR:
            IMPORTER.reset()
            output = Output(settings)
            runner = JudasRunner(rf_test_to_actual, output, settings)
            suite.visit(runner)
        output.close(runner.result)
    return runner.result
Example #6
0
 def main(self, datasources, **options):
     settings = RobotSettings(options)
     LOGGER.register_console_logger(**settings.console_output_config)
     LOGGER.info("Settings:\n%s" % unic(settings))
     suite = TestSuiteBuilder(settings["SuiteNames"], settings["WarnOnSkipped"]).build(*datasources)
     suite.configure(**settings.suite_config)
     if settings.pre_run_modifiers:
         suite.visit(ModelModifier(settings.pre_run_modifiers, settings.run_empty_suite, LOGGER))
     with pyloggingconf.robot_handler_enabled(settings.log_level):
         result = suite.run(settings)
         LOGGER.info("Tests execution ended. Statistics:\n%s" % result.suite.stat_message)
         if settings.log or settings.report or settings.xunit:
             writer = ResultWriter(settings.output if settings.log else result)
             writer.write_results(settings.get_rebot_settings())
     return result.return_code
Example #7
0
 def main(self, datasources, **options):
     settings = RobotSettings(options)
     LOGGER.register_console_logger(**settings.console_logger_config)
     LOGGER.info('Settings:\n%s' % unicode(settings))
     suite = TestSuiteBuilder(settings['SuiteNames'],
                              settings['WarnOnSkipped'],
                              settings['RunEmptySuite']).build(*datasources)
     suite.configure(**settings.suite_config)
     with pyloggingconf.robot_handler_enabled(settings.log_level):
         result = suite.run(settings)
         LOGGER.info("Tests execution ended. Statistics:\n%s"
                     % result.suite.stat_message)
         if settings.log or settings.report or settings.xunit:
             writer = ResultWriter(settings.output if settings.log
                                   else result)
             writer.write_results(settings.get_rebot_settings())
     return 0  # result.return_code
Example #8
0
 def main(self, datasources, **options):
     settings = RobotSettings(options)
     LOGGER.register_console_logger(**settings.console_logger_config)
     LOGGER.info('Settings:\n%s' % unicode(settings))
     suite = TestSuiteBuilder(settings['SuiteNames'],
                              settings['WarnOnSkipped'],
                              settings['RunEmptySuite']).build(*datasources)
     suite.configure(**settings.suite_config)
     with pyloggingconf.robot_handler_enabled(settings.log_level):
         result = suite.run(settings)
         LOGGER.info("Tests execution ended. Statistics:\n%s" %
                     result.suite.stat_message)
         if settings.log or settings.report or settings.xunit:
             writer = ResultWriter(
                 settings.output if settings.log else result)
             writer.write_results(settings.get_rebot_settings())
     return result.return_code
Example #9
0
 def main(self, datasources, **options):
     try:
         settings = RobotSettings(options)
     except:
         LOGGER.register_console_logger(stdout=options.get('stdout'),
                                        stderr=options.get('stderr'))
         raise
     LOGGER.register_console_logger(**settings.console_output_config)
     LOGGER.info(f'Settings:\n{settings}')
     if settings.pythonpath:
         sys.path = settings.pythonpath + sys.path
     builder = TestSuiteBuilder(settings.suite_names,
                                included_extensions=settings.extension,
                                rpa=settings.rpa,
                                lang=settings.languages,
                                allow_empty_suite=settings.run_empty_suite)
     suite = builder.build(*datasources)
     settings.rpa = suite.rpa
     if settings.pre_run_modifiers:
         suite.visit(
             ModelModifier(settings.pre_run_modifiers,
                           settings.run_empty_suite, LOGGER))
     suite.configure(**settings.suite_config)
     with pyloggingconf.robot_handler_enabled(settings.log_level):
         old_max_error_lines = text.MAX_ERROR_LINES
         old_max_assign_length = text.MAX_ASSIGN_LENGTH
         text.MAX_ERROR_LINES = settings.max_error_lines
         text.MAX_ASSIGN_LENGTH = settings.max_assign_length
         try:
             result = suite.run(settings)
         finally:
             text.MAX_ERROR_LINES = old_max_error_lines
             text.MAX_ASSIGN_LENGTH = old_max_assign_length
         LOGGER.info("Tests execution ended. Statistics:\n%s" %
                     result.suite.stat_message)
         if settings.log or settings.report or settings.xunit:
             writer = ResultWriter(
                 settings.output if settings.log else result)
             writer.write_results(settings.get_rebot_settings())
     return result.return_code
Example #10
0
    def run(self, settings=None, **options):
        """Executes the suite based based the given ``settings`` or ``options``.

        :param settings: :class:`~robot.conf.settings.RobotSettings` object
            to configure test execution.
        :param options: Used to construct new
            :class:`~robot.conf.settings.RobotSettings` object if ``settings``
            are not given.
        :return: :class:`~robot.result.executionresult.Result` object with
            information about executed suites and tests.

        If ``options`` are used, their names are the same as long command line
        options except without hyphens. Some options are ignored (see below),
        but otherwise they have the same semantics as on the command line.
        Options that can be given on the command line multiple times can be
        passed as lists like ``variable=['VAR1:value1', 'VAR2:value2']``.
        If such an option is used only once, it can be given also as a single
        string like ``variable='VAR:value'``.

        Additionally listener option allows passing object directly instead of
        listener name, e.g. ``run('tests.robot', listener=Listener())``.

        To capture stdout and/or stderr streams, pass open file objects in as
        special keyword arguments ``stdout`` and ``stderr``, respectively.

        Only options related to the actual test execution have an effect.
        For example, options related to selecting or modifying test cases or
        suites (e.g. ``--include``, ``--name``, ``--prerunmodifier``) or
        creating logs and reports are silently ignored. The output XML
        generated as part of the execution can be configured, though. This
        includes disabling it with ``output=None``.

        Example::

            stdout = StringIO()
            result = suite.run(variable='EXAMPLE:value',
                               critical='regression',
                               output='example.xml',
                               exitonfailure=True,
                               stdout=stdout)
            print result.return_code

        To save memory, the returned
        :class:`~robot.result.executionresult.Result` object does not
        have any information about the executed keywords. If that information
        is needed, the created output XML file needs to be read  using the
        :class:`~robot.result.resultbuilder.ExecutionResult` factory method.

        See the :mod:`package level <robot.running>` documentation for
        more examples, including how to construct executable test suites and
        how to create logs and reports based on the execution results.

        See the :func:`robot.run <robot.run.run>` function for a higher-level
        API for executing tests in files or directories.
        """
        from .namespace import IMPORTER
        from .signalhandler import STOP_SIGNAL_MONITOR
        from .runner import Runner

        with LOGGER:
            if not settings:
                settings = RobotSettings(options)
                LOGGER.register_console_logger(
                    **settings.console_output_config)
            with pyloggingconf.robot_handler_enabled(settings.log_level):
                with STOP_SIGNAL_MONITOR:
                    IMPORTER.reset()
                    output = Output(settings)
                    runner = Runner(output, settings)
                    self.visit(runner)
                output.close(runner.result)
        return runner.result
Example #11
0
    def run(self, settings=None, **options):
        """Executes the suite based based the given ``settings`` or ``options``.

        :param settings: :class:`~robot.conf.settings.RobotSettings` object
            to configure test execution.
        :param options: Used to construct new
            :class:`~robot.conf.settings.RobotSettings` object if ``settings``
            are not given.
        :return: :class:`~robot.result.executionresult.Result` object with
            information about executed suites and tests.

        If ``options`` are used, their names are the same as long command line
        options except without hyphens, and they also have the same semantics.
        Options that can be given on the command line multiple times can be
        passed as lists like ``variable=['VAR1:value1', 'VAR2:value2']``.
        If such an option is used only once, it can be given also as a single
        string like ``variable='VAR:value'``.

        To capture stdout and/or stderr streams, pass open file objects in as
        special keyword arguments `stdout` and `stderr`, respectively. Note
        that this works only in version 2.8.4 and newer.

        Only options related to the actual test execution have an effect.
        For example, options related to selecting test cases or creating
        logs and reports are silently ignored. The output XML generated
        as part of the execution can be configured, though. This includes
        disabling it with ``output=None``.

        Example::

            stdout = StringIO()
            result = suite.run(variable='EXAMPLE:value',
                               critical='regression',
                               output='example.xml',
                               exitonfailure=True,
                               stdout=stdout)
            print result.return_code

        To save memory, the returned
        :class:`~robot.result.executionresult.Result` object does not
        have any information about the executed keywords. If that information
        is needed, the created output XML file needs to be read  using the
        :class:`~robot.result.resultbuilder.ExecutionResult` factory method.

        See the :mod:`package level <robot.running>` documentation for
        more examples, including how to construct executable test suites and
        how to create logs and reports based on the execution results.

        See the :func:`robot.run <robot.run.run>` function for a higher-level
        API for executing tests in files or directories.
        """
        if not settings:
            settings = RobotSettings(options)
            LOGGER.register_console_logger(**settings.console_logger_config)
        with pyloggingconf.robot_handler_enabled(settings.log_level):
            with STOP_SIGNAL_MONITOR:
                IMPORTER.reset()
                init_global_variables(settings)
                output = Output(settings)
                runner = Runner(output, settings)
                self.visit(runner)
            output.close(runner.result)
        return runner.result