Make robot driver even more generic 81/73481/3
authorCédric Ollivier <cedric.ollivier@orange.com>
Fri, 23 Sep 2022 08:48:26 +0000 (10:48 +0200)
committerCédric Ollivier <cedric.ollivier@orange.com>
Fri, 23 Sep 2022 10:21:59 +0000 (12:21 +0200)
It allows setting any option via testcases.yaml

Change-Id: I8cb5ead037a65f962c3ba1a14729b52195e95483
Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
xtesting/core/robotframework.py
xtesting/tests/unit/core/test_robotframework.py

index 2952de6..92b7593 100644 (file)
@@ -106,10 +106,7 @@ class RobotFramework(testcase.TestCase):
             EX_RUN_ERROR otherwise.
         """
         try:
-            suites = kwargs["suites"]
-            variable = kwargs.get("variable", [])
-            variablefile = kwargs.get("variablefile", [])
-            include = kwargs.get("include", [])
+            suites = kwargs.pop("suites")
         except KeyError:
             self.__logger.exception("Mandatory args were not passed")
             return self.EX_RUN_ERROR
@@ -120,9 +117,11 @@ class RobotFramework(testcase.TestCase):
                 self.__logger.exception("Cannot create %s", self.res_dir)
                 return self.EX_RUN_ERROR
         stream = StringIO()
-        robot.run(*suites, variable=variable, variablefile=variablefile,
-                  include=include, output=self.xml_file, log='NONE',
-                  report='NONE', stdout=stream)
+        kwargs["output"] = self.xml_file
+        kwargs["log"] = "NONE"
+        kwargs["report"] = "NONE"
+        kwargs["stdout"] = stream
+        robot.run(*suites, **kwargs)
         self.__logger.info("\n%s", stream.getvalue())
         try:
             self.parse_results()
index bbd99f5..ca68182 100644 (file)
@@ -215,11 +215,16 @@ class RunTesting(unittest.TestCase):
 
     @mock.patch('robot.run')
     def _test_makedirs(self, *args):
+        kwargs = {
+            'variable': self.variable,
+            'variablefile': self.variablefile,
+            'include': self.include
+        }
         with mock.patch.object(self.test, 'parse_results') as mock_method, \
                 mock.patch.object(self.test, 'generate_report',
                                   return_value=0) as mmethod:
             self.assertEqual(
-                self.test.run(suites=self.suites, variable=self.variable),
+                self.test.run(suites=self.suites, **kwargs),
                 self.test.EX_OK)
             args[0].assert_called_once_with(
                 *self.suites, log='NONE', output=self.test.xml_file,
@@ -245,10 +250,13 @@ class RunTesting(unittest.TestCase):
     @mock.patch('os.makedirs')
     @mock.patch('robot.run')
     def _test_parse_results(self, status, *args):
+        kwargs = {
+            'variable': self.variable,
+            'variablefile': self.variablefile,
+            'include': self.include
+        }
         self.assertEqual(
-            self.test.run(
-                suites=self.suites, variable=self.variable,
-                variablefile=self.variablefile, include=self.include),
+            self.test.run(suites=self.suites, **kwargs),
             status)
         args[0].assert_called_once_with(
             *self.suites, log='NONE', output=self.test.xml_file,
@@ -275,11 +283,14 @@ class RunTesting(unittest.TestCase):
     @mock.patch('os.makedirs')
     @mock.patch('robot.run')
     def _test_generate_report(self, status, *args):
+        kwargs = {
+            'variable': self.variable,
+            'variablefile': self.variablefile,
+            'include': self.include
+        }
         with mock.patch.object(self.test, 'parse_results') as mock_method:
             self.assertEqual(
-                self.test.run(
-                    suites=self.suites, variable=self.variable,
-                    variablefile=self.variablefile, include=self.include),
+                self.test.run(suites=self.suites, **kwargs),
                 status)
         args[0].assert_called_once_with(
             *self.suites, log='NONE', output=self.test.xml_file,