def test__variable_kw__pass():
    suite = TestSuiteBuilder().build(
        os.path.join(path, 'fixtures/robot/variable.robot'))
    result = suite.run(output=None,
                       variablefile=os.path.join(path,
                                                 'fixtures/robot/common.py'))

    assert result.return_code == 0
Пример #2
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)
     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
Пример #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))
     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
Пример #4
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)
     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
Пример #5
0
 def main(self, datasources, **options):
     settings = RobotSettings(options)
     LOGGER.register_console_logger(**settings.console_output_config)
     LOGGER.info('Settings:\n%s' % unicode(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
Пример #6
0
 def _runTest(self, parsed, **options):
     settings = RobotSettings(options)
     LOGGER.register_console_logger(width=settings['MonitorWidth'],
                                    colors=settings['MonitorColors'],
                                    markers=settings['MonitorMarkers'],
                                    stdout=settings['StdOut'],
                                    stderr=settings['StdErr'])
     LOGGER.info('Settings:\n%s' % six.text_type(settings))
     suite = TestSuiteBuilder(
         settings['SuiteNames'], settings['WarnOnSkipped'],
         settings['RunEmptySuite'])._build_suite(parsed)
     suite.configure(**settings.suite_config)
     result = suite.run(settings)
     LOGGER.info("Tests execution ended. Statistics:\n%s" %
                 result.suite.statistics.message)
     rc = result.return_code
     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 rc
Пример #7
0
 def _runTest(self, parsed, **options):
     settings = RobotSettings(options)
     LOGGER.register_console_logger(width=settings['MonitorWidth'],
                                    colors=settings['MonitorColors'],
                                    markers=settings['MonitorMarkers'],
                                    stdout=settings['StdOut'],
                                    stderr=settings['StdErr'])
     LOGGER.info('Settings:\n%s' % six.text_type(settings))
     suite = TestSuiteBuilder(
         settings['SuiteNames'],
         settings['WarnOnSkipped'],
         settings['RunEmptySuite'])._build_suite(parsed)
     suite.configure(**settings.suite_config)
     result = suite.run(settings)
     LOGGER.info("Tests execution ended. Statistics:\n%s"
                 % result.suite.statistics.message)
     rc = result.return_code
     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 rc
Пример #8
0
class RobotFramework(Application):
    def __init__(self):
        self.logger1 = new_logger_for_thread()
        Application.__init__(self,
                             USAGE,
                             arg_limits=(1, ),
                             env_options='ROBOT_OPTIONS',
                             logger=self.logger1)
        self.settings = None
        self.suite = None

    def main(self, datasources, **options):
        self.settings = RobotSettings(options)
        self.logger1.register_console_logger(
            **self.settings.console_output_config)
        self.logger1.info('Settings:\n%s' % unic(self.settings))
        self.suite = TestSuiteBuilder(
            self.settings['SuiteNames'],
            self.settings['WarnOnSkipped']).build(*datasources)
        self.suite.configure(**self.settings.suite_config)
        if self.settings.pre_run_modifiers:
            self.suite.visit(
                ModelModifier(self.settings.pre_run_modifiers,
                              self.settings.run_empty_suite, self.logger1))
        with pyloggingconf.robot_handler_enabled(self.settings.log_level):
            result = self.suite.run(self.settings)
            self.logger1.info("Tests execution ended. Statistics:\n%s" %
                              result.suite.stat_message)
            if self.settings.log or self.settings.report or self.settings.xunit:
                writer = ResultWriter(
                    self.settings.output if self.settings.log else result)
                writer.write_results(self.settings.get_rebot_settings())
        return result.return_code

    def validate(self, options, arguments):
        return self._filter_options_without_value(options), arguments

    def _filter_options_without_value(self, options):
        return dict((name, value) for name, value in options.items()
                    if value not in (None, []))
Пример #9
0
 def _runTest(self, parsed, **options):
     settings = RobotSettings(options)
     output_config = getattr(settings, 'console_output_config', {
         'width': getattr(settings, 'console_width', 78),
         'colors': getattr(settings, 'console_colors', 'AUTO'),
         'markers': getattr(settings, 'console_markers', 'AUTO'),
         'stdout': settings['StdOut'],
         'stderr': settings['StdErr']
     })
     LOGGER.register_console_logger(**output_config)
     LOGGER.info('Settings:\n%s' % six.text_type(settings))
     suite = TestSuiteBuilder(
         settings['SuiteNames'],
         settings['WarnOnSkipped'])._build_suite(parsed)
     suite.configure(**settings.suite_config)
     result = suite.run(settings)
     LOGGER.info("Tests execution ended. Statistics:\n%s"
                 % result.suite.statistics.message)
     rc = result.return_code
     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 rc
Пример #10
0
 def _runTest(self, parsed, **options):
     settings = RobotSettings(options)
     output_config = getattr(
         settings, 'console_output_config', {
             'width': getattr(settings, 'console_width', 78),
             'colors': getattr(settings, 'console_colors', 'AUTO'),
             'markers': getattr(settings, 'console_markers', 'AUTO'),
             'stdout': settings['StdOut'],
             'stderr': settings['StdErr']
         })
     LOGGER.register_console_logger(**output_config)
     LOGGER.info('Settings:\n%s' % six.text_type(settings))
     suite = TestSuiteBuilder(
         settings['SuiteNames'],
         settings['WarnOnSkipped'])._build_suite(parsed)
     suite.configure(**settings.suite_config)
     result = suite.run(settings)
     LOGGER.info("Tests execution ended. Statistics:\n%s" %
                 result.suite.statistics.message)
     rc = result.return_code
     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 rc
def test__enforce_validation():
    suite = TestSuiteBuilder().build(os.path.join(os.getcwd(), 'tests', 'fixtures', 'robot', 'context_only.robot'))
    result = suite.run(output=None, variablefile=os.path.join('fixtures/robot/common.py'))

    assert result.statistics.total.all.failed > 0
Пример #12
0
from robot.running import TestSuiteBuilder

suite = TestSuiteBuilder().build("./google_search.robot")
result = suite.run()

__author__ = 'teemu kanstren'

from robot.running import TestSuiteBuilder
from robot.api import ResultWriter

#https://robot-framework.readthedocs.io/en/3.0/autodoc/robot.running.html
suite = TestSuiteBuilder().build("./noncritical.robot")
#this tag does not exist in the given suite, so no critical tests should be listed in report
result = suite.run(noncritical="non")
ResultWriter(result).write_results(report='report.html', log="log.html")
Пример #14
0
def _run(suite_path, test_case, results_dir):
    suite = TestSuiteBuilder().build(suite_path)
    suite.configure(include_tests=test_case.decode('utf-8'))
    result = suite.run(output='{0}/{1}.xml'.format(results_dir, test_case).decode('utf-8'))
    return {'passed': result.statistics.suite.stat.passed, 'failed': result.statistics.suite.stat.failed}
Пример #15
0
class InteractiveRunner(LoggingConfigurable):
    """ An interactive Robot Framework runner
    """
    def __init__(self, silent=False):
        super().__init__()
        self.silent = silent
        self._tmpdir = TemporaryDirectory()
        self.path = Path(self._tmpdir.name)

        self.suite = None
        self.results = None
        self.stdout = None
        self._handlers = defaultdict(list)

        self.test_data = irobot.TestCaseString()

    def __del__(self):
        self._tmpdir.cleanup()

    @property
    def failed(self):
        """ wrapper for crazy-long path
        """
        try:
            return self.results.statistics.total.critical.failed
        except AttributeError:
            return 0

    def populate(self, *code):
        """ Populate with some code lines
        """
        list(map(self.test_data.populate, code))
        return self

    def clear_tests(self):
        """ Clear the tests table
        """
        self.test_data.testcase_table.tests.clear()
        return self

    def build(self, name="Untitled Test Suite"):
        """ Build a test suite
        """
        # pylint: disable=W0212
        self.suite = TestSuiteBuilder()._build_suite(self.test_data)
        self.suite._name = name
        return self

    def on_suite(self, handler):
        """ Set a listener for start events
        """
        self._handlers[irobot.SuiteEventListener].append(handler)

    def on_status(self, handler):
        """ Set a listener for status events
        """
        self._handlers[irobot.StatusEventListener].append(handler)

    def on_return_value(self, handler):
        """ Set a listener for return values
        """
        self._handlers[irobot.ReturnValueListener].append(handler)

    def on_import(self, handler):
        """ Set a listener for imports
        """
        self._handlers[irobot.ImportListener].append(handler)

    def run(self):
        """ Run the built suite
        """
        with importnb.Notebook():
            with StringIO() as stdout:
                self.results = self.suite.run(
                    outputdir=str(self.path),
                    stdout=stdout,
                    listener=sum(
                        [
                            list(map(klass, handlers))
                            for klass, handlers in self._handlers.items()
                        ],
                        [],
                    ),
                )
                self.stdout = stdout.getvalue().strip().splitlines()

        return self
def test__address__pass():

    suite = TestSuiteBuilder().build(os.path.join(os.getcwd(), 'app2.robot'))
    result = suite.run(output=None)

    assert result.return_code == 0
Пример #17
0
__author__ = 'teemu kanstren'

from robot.running import TestSuiteBuilder
from robot.api import ResultWriter

#https://robot-framework.readthedocs.io/en/3.0/autodoc/robot.running.html
suite = TestSuiteBuilder().build("./noncritical.robot")
result = suite.run(output="test_output.xml", noncritical="*crit")
ResultWriter("test_output.xml").write_results(report='report.html', log="log.html")
Пример #18
0
__author__ = 'teemu kanstren'

from robot.running import TestSuiteBuilder
from robot.api import ResultWriter

#https://robot-framework.readthedocs.io/en/3.0/autodoc/robot.running.html
suite = TestSuiteBuilder().build("./library.robot")
result = suite.run(output="test_output.xml")
#ResultWriter(result).write_results(report='report.html', log="log.html")
ResultWriter("test_output.xml").write_results(report='report.html',
                                              log="log.html")
__author__ = 'teemu kanstren'

from robot.running import TestSuiteBuilder
from robot.api import ResultWriter
from io import StringIO

#https://robot-framework.readthedocs.io/en/3.0/autodoc/robot.running.html
suite = TestSuiteBuilder().build("./include.robot")
stdout = StringIO()
result = suite.run(output="test_output.xml", include="*crit", stdout=stdout)
ResultWriter("test_output.xml").write_results(report='report.html',
                                              log="log.html")
output = stdout.getvalue()
print(output)