Exemplo n.º 1
0
    def test_selenium_startup_shutdown_python_single(self):
        """
        run tests from .py file
        :return:
        """

        obj = SeleniumExecutor()
        obj.engine = EngineEmul()
        obj.engine.config = BetterDict()
        obj.engine.config.merge(yaml.load(open("tests/yaml/selenium_executor_python.yml").read()))
        obj.engine.config.merge({"provisioning": "local"})
        obj.execution = obj.engine.config["execution"]

        obj.execution.merge({"scenario": {"script": ABS_PATH("/../../tests/selenium/python/test_blazemeter_fail.py")}})

        obj.settings.merge(obj.engine.config.get("modules").get("selenium"))
        obj.prepare()
        obj.startup()
        while not obj.check():
            time.sleep(1)
        obj.shutdown()
        prepared_files = os.listdir(obj.runner.working_dir)
        python_files = [file for file in prepared_files if file.endswith(".py")]
        self.assertEqual(1, len(python_files))
        self.assertTrue(os.path.exists(obj.runner.settings.get("report-file")))
Exemplo n.º 2
0
 def test_selenium_startup_shutdown_java_package(self):
     """
     Run tests from package
     :return:
     """
     obj = SeleniumExecutor()
     obj.engine = self.engine_obj
     obj.settings = self.selenium_config
     obj.engine.config.merge({
         'execution': {
             'scenario': {
                 'script': 'tests/selenium/java_package/'
             },
             'executor': 'selenium'
         },
         'reporting': [{
             'module': 'junit-xml'
         }]
     })
     obj.engine.config.merge({"provisioning": "local"})
     obj.execution = obj.engine.config['execution']
     obj.settings.merge(obj.engine.config.get("modules").get("selenium"))
     obj.prepare()
     obj.startup()
     while not obj.check():
         time.sleep(1)
     obj.shutdown()
     self.assertTrue(
         os.path.exists(os.path.join(obj.runner.working_dir,
                                     "compiled.jar")))
Exemplo n.º 3
0
    def test_selenium_startup_shutdown_java_folder(self):
        """
        run tests from .java files
        :return:
        """
        obj = SeleniumExecutor()
        obj.engine = self.engine_obj
        obj.settings = self.selenium_config
        obj.engine.config.merge(
            {'execution': {'scenario': {'script': __dir__() + '/../selenium/java/'}, 'executor': 'selenium'},
             'reporting': [{'module': 'junit-xml'}]})
        obj.engine.config.merge({"provisioning": "local"})
        obj.execution = obj.engine.config['execution']
        obj.settings.merge(obj.engine.config.get("modules").get("selenium"))
        obj.prepare()
        obj.startup()
        while not obj.check():
            time.sleep(1)
        obj.shutdown()

        prepared_files = os.listdir(obj.runner.working_dir)
        java_files = [fname for fname in prepared_files if fname.endswith(".java")]
        class_files = [fname for fname in prepared_files if fname.endswith(".class")]
        jars = [fname for fname in prepared_files if fname.endswith(".jar")]
        self.assertEqual(2, len(java_files))
        self.assertEqual(2, len(class_files))
        self.assertEqual(1, len(jars))
        self.assertTrue(os.path.exists(os.path.join(obj.runner.working_dir, "compiled.jar")))
        self.assertTrue(os.path.exists(obj.runner.settings.get("report-file")))
Exemplo n.º 4
0
    def test_selenium_startup_shutdown_java_folder(self):
        """
        run tests from .java files
        :return:
        """
        obj = SeleniumExecutor()
        obj.engine = EngineEmul()
        obj.engine.config.merge(
            yaml.load(open("tests/yaml/selenium_executor_java.yml").read()))
        obj.engine.config.merge({"provisioning": "local"})
        obj.execution = obj.engine.config['execution']
        obj.settings.merge(obj.engine.config.get("modules").get("selenium"))
        obj.prepare()
        obj.startup()
        while not obj.check():
            time.sleep(1)
        obj.shutdown()

        prepared_files = os.listdir(obj.runner.working_dir)
        java_files = [
            file for file in prepared_files if file.endswith(".java")
        ]
        class_files = [
            file for file in prepared_files if file.endswith(".class")
        ]
        jars = [file for file in prepared_files if file.endswith(".jar")]
        self.assertEqual(2, len(java_files))
        self.assertEqual(2, len(class_files))
        self.assertEqual(1, len(jars))
        self.assertTrue(
            os.path.exists(os.path.join(obj.runner.working_dir,
                                        "compiled.jar")))
        self.assertTrue(os.path.exists(obj.runner.report_file))
Exemplo n.º 5
0
 def runner_fail_no_test_found(self):
     """
     Check that Python Nose runner fails if no tests were found
     :return:
     """
     obj = SeleniumExecutor()
     obj.engine = EngineEmul()
     obj.engine.config = BetterDict()
     obj.engine.config.merge({
         "execution": {
             "executor": "selenium",
             "scenario": {
                 "script": "tests/selenium/invalid/dummy.py"
             }
         }
     })
     obj.execution = obj.engine.config['execution']
     obj.prepare()
     obj.startup()
     try:
         while not obj.check():
             time.sleep(1)
     except BaseException as exc:
         self.assertEqual(
             exc.args[0],
             "Test runner NoseTester has failed: Nothing to test.")
     obj.shutdown()
Exemplo n.º 6
0
 def test_samples_count_annotations(self):
     """
     Test exact number of tests when java annotations used
     :return:
     """
     obj = SeleniumExecutor()
     obj.engine = self.engine_obj
     obj.settings = self.selenium_config
     obj.engine.config.merge({
         "execution": {
             "executor": "selenium",
             "scenario": {
                 "script": "tests/selenium/invalid/SeleniumTest.java"
             }
         }
     })
     obj.execution = obj.engine.config['execution']
     obj.prepare()
     obj.startup()
     while not obj.check():
         time.sleep(1)
     obj.shutdown()
     with open(obj.kpi_file) as kpi_fds:
         reader = csv.reader(kpi_fds)
         rows = list(reader)
     self.assertEqual(len(rows), 3)
Exemplo n.º 7
0
 def runner_fail_no_test_found(self):
     """
     Check that Python Nose runner fails if no tests were found
     :return:
     """
     obj = SeleniumExecutor()
     obj.engine = EngineEmul()
     obj.engine.config.merge({
         ScenarioExecutor.EXEC: {
             "executor": "selenium",
             "scenario": {
                 "script": __dir__() + "/../selenium/invalid/dummy.py"
             }
         }
     })
     obj.execution = obj.engine.config['execution']
     obj.prepare()
     obj.startup()
     try:
         while not obj.check():
             time.sleep(1)
         self.fail()
     except RuntimeError as exc:
         self.assertIn("Nothing to test.", exc.args[0])
     obj.shutdown()
Exemplo n.º 8
0
    def test_selenium_startup_shutdown_jar_single(self):
        """
        runt tests from single jar
        :return:
        """
        obj = SeleniumExecutor()
        obj.engine = self.engine_obj
        obj.settings = self.selenium_config
        obj.engine.config.merge(yaml.load(open("tests/yaml/selenium_executor_jar.yml").read()))
        obj.engine.config.merge({"provisioning": "local"})
        obj.execution = obj.engine.config["execution"]
        obj.execution.merge({"scenario": {"script": ABS_PATH("/../../tests/selenium/jar/dummy.jar")}})
        obj.settings.merge(obj.engine.config.get("modules").get("selenium"))
        obj.prepare()
        obj.startup()
        while not obj.check():
            time.sleep(1)
        obj.shutdown()

        prepared_files = os.listdir(obj.runner.working_dir)
        java_files = [file for file in prepared_files if file.endswith(".java")]
        class_files = [file for file in prepared_files if file.endswith(".class")]
        jars = [file for file in prepared_files if file.endswith(".jar")]
        self.assertEqual(len(java_files), 0)
        self.assertEqual(len(class_files), 0)
        self.assertEqual(len(jars), 1)
        self.assertTrue(os.path.exists(obj.runner.settings.get("report-file")))
Exemplo n.º 9
0
 def test_not_junit(self):
     """
     Check that JUnit runner fails if no tests were found
     :return:
     """
     obj = SeleniumExecutor()
     obj.engine = self.engine_obj
     obj.settings = self.selenium_config
     obj.engine.config = BetterDict()
     obj.engine.config.merge({
         "execution": {
             "executor": "selenium",
             "scenario": {
                 "script": "tests/selenium/invalid/NotJUnittest.java"
             }
         }
     })
     obj.execution = obj.engine.config['execution']
     obj.prepare()
     obj.startup()
     try:
         while not obj.check():
             time.sleep(1)
         self.fail()
     except BaseException as exc:
         self.assertIn("Nothing to test", exc.args[0])
     obj.shutdown()
Exemplo n.º 10
0
    def test_selenium_startup_shutdown_java_folder(self):
        """
        run tests from .java files
        :return:
        """
        obj = SeleniumExecutor()
        obj.engine = self.engine_obj
        obj.settings = self.selenium_config
        obj.engine.config.merge(yaml.load(open("tests/yaml/selenium_executor_java.yml").read()))
        obj.engine.config.merge({"provisioning": "local"})
        obj.execution = obj.engine.config["execution"]
        obj.settings.merge(obj.engine.config.get("modules").get("selenium"))
        obj.prepare()
        obj.startup()
        while not obj.check():
            time.sleep(1)
        obj.shutdown()

        prepared_files = os.listdir(obj.runner.working_dir)
        java_files = [file for file in prepared_files if file.endswith(".java")]
        class_files = [file for file in prepared_files if file.endswith(".class")]
        jars = [file for file in prepared_files if file.endswith(".jar")]
        self.assertEqual(2, len(java_files))
        self.assertEqual(2, len(class_files))
        self.assertEqual(1, len(jars))
        self.assertTrue(os.path.exists(os.path.join(obj.runner.working_dir, "compiled.jar")))
        self.assertTrue(os.path.exists(obj.runner.settings.get("report-file")))
Exemplo n.º 11
0
 def test_selenium_startup_shutdown_python_folder(self):
     """
     run tests from .py files
     :return:
     """
     obj = SeleniumExecutor()
     obj.engine = EngineEmul()
     obj.engine.config.merge({
         'execution': {
             'scenario': {
                 'script': __dir__() + '/../selenium/python/'
             },
             'executor': 'selenium'
         },
         'reporting': [{
             'module': 'junit-xml'
         }]
     })
     obj.engine.config.merge({"provisioning": "local"})
     obj.execution = obj.engine.config['execution']
     obj.settings.merge(obj.engine.config.get("modules").get("selenium"))
     obj.prepare()
     obj.startup()
     while not obj.check():
         time.sleep(1)
     obj.shutdown()
     prepared_files = os.listdir(obj.runner.working_dir)
     python_files = [
         fname for fname in prepared_files if fname.endswith(".py")
     ]
     self.assertEqual(2, len(python_files))
     self.assertTrue(os.path.exists(obj.runner.settings.get("report-file")))
Exemplo n.º 12
0
 def test_not_junit(self):
     """
     Check that JUnit runner fails if no tests were found
     :return:
     """
     obj = SeleniumExecutor()
     obj.engine = EngineEmul()
     obj.engine.config = BetterDict()
     obj.engine.config.merge({
         "execution": {
             "executor": "selenium",
             "scenario": {
                 "script": "tests/selenium/invalid/NotJUnittest.java"
             }
         }
     })
     obj.execution = obj.engine.config['execution']
     obj.prepare()
     obj.startup()
     try:
         while not obj.check():
             time.sleep(1)
     except BaseException as exc:
         self.assertEqual(
             exc.args[0],
             "Test runner JunitTester has failed: There is nothing to test."
         )
     obj.shutdown()
Exemplo n.º 13
0
    def test_selenium_startup_shutdown_jar_single(self):
        """
        runt tests from single jar
        :return:
        """
        obj = SeleniumExecutor()
        obj.engine = self.engine_obj
        obj.settings = self.selenium_config
        obj.engine.config.merge(
            {'execution': {'scenario': {'script': __dir__() + '/../selenium/jar/'}, 'executor': 'selenium'},
             'reporting': [{'module': 'junit-xml'}]})
        obj.engine.config.merge({"provisioning": "local"})
        obj.execution = obj.engine.config['execution']
        obj.execution.merge(
            {"scenario": {"script": __dir__() + "/../selenium/jar/dummy.jar"}})
        obj.settings.merge(obj.engine.config.get("modules").get("selenium"))
        obj.prepare()
        obj.startup()
        while not obj.check():
            time.sleep(1)
        obj.shutdown()

        prepared_files = os.listdir(obj.runner.working_dir)
        java_files = [fname for fname in prepared_files if fname.endswith(".java")]
        class_files = [fname for fname in prepared_files if fname.endswith(".class")]
        jars = [fname for fname in prepared_files if fname.endswith(".jar")]
        self.assertEqual(len(java_files), 0)
        self.assertEqual(len(class_files), 0)
        self.assertEqual(len(jars), 1)
        self.assertTrue(os.path.exists(obj.runner.settings.get("report-file")))
Exemplo n.º 14
0
    def test_selenium_startup_shutdown_python_single(self):
        """
        run tests from .py file
        :return:
        """

        obj = SeleniumExecutor()
        obj.engine = EngineEmul()
        obj.engine.config = BetterDict()
        obj.engine.config.merge(
            yaml.load(open("tests/yaml/selenium_executor_python.yml").read()))
        obj.engine.config.merge({"provisioning": "local"})
        obj.execution = obj.engine.config['execution']

        obj.execution.merge({
            "scenario": {
                "script":
                os.path.abspath(
                    __dir__() +
                    "/../../tests/selenium/python/test_blazemeter_fail.py")
            }
        })

        obj.settings.merge(obj.engine.config.get("modules").get("selenium"))
        obj.prepare()
        obj.startup()
        while not obj.check():
            time.sleep(1)
        obj.shutdown()
        prepared_files = os.listdir(obj.runner.working_dir)
        python_files = [
            file for file in prepared_files if file.endswith(".py")
        ]
        self.assertEqual(1, len(python_files))
        self.assertTrue(os.path.exists(obj.runner.report_file))
Exemplo n.º 15
0
    def test_selenium_startup_shutdown_java_single(self):
        """
        run tests from single .java file
        :return:
        """
        obj = SeleniumExecutor()
        obj.engine = EngineEmul()
        obj.engine.config.merge(yaml.load(open("tests/yaml/selenium_executor_java.yml").read()))
        obj.engine.config.merge({"provisioning": "local"})
        obj.execution = obj.engine.config['execution']
        obj.execution.merge(
            {"scenario": {"script": os.path.abspath(__dir__() + "/../../tests/selenium/java/TestBlazemeterFail.java")}})
        obj.settings.merge(obj.engine.config.get("modules").get("selenium"))
        obj.prepare()
        obj.startup()
        while not obj.check():
            time.sleep(1)
        obj.shutdown()

        prepared_files = os.listdir(obj.runner.working_dir)
        java_files = [file for file in prepared_files if file.endswith(".java")]
        class_files = [file for file in prepared_files if file.endswith(".class")]
        jars = [file for file in prepared_files if file.endswith(".jar")]
        self.assertEqual(1, len(java_files))
        self.assertEqual(1, len(class_files))
        self.assertEqual(1, len(jars))
        self.assertTrue(os.path.exists(os.path.join(obj.runner.working_dir, "compiled.jar")))
        self.assertTrue(os.path.exists(obj.runner.report_file))
Exemplo n.º 16
0
 def test_samples_count_testcase(self):
     """
     Test exact number of tests when test class extends JUnit TestCase
     :return:
     """
     obj = SeleniumExecutor()
     obj.engine = self.engine_obj
     obj.settings = self.selenium_config
     obj.engine.config.merge({
         ScenarioExecutor.EXEC: {
             "executor": "selenium",
             "scenario": {
                 "script":
                 __dir__() + "/../selenium/invalid/SimpleTest.java"
             }
         }
     })
     obj.execution = obj.engine.config['execution']
     obj.prepare()
     obj.startup()
     while not obj.check():
         time.sleep(1)
     obj.shutdown()
     with open(obj.kpi_file) as kpi_fds:
         reader = csv.reader(kpi_fds)
         rows = list(reader)
     self.assertEqual(len(rows), 3)
Exemplo n.º 17
0
 def test_no_test_in_name(self):
     """
     Test exact number of tests when annotations used and no "test" in class name
     :return:
     """
     obj = SeleniumExecutor()
     obj.engine = EngineEmul()
     obj.engine.config = BetterDict()
     obj.engine.config.merge({
         "execution": {
             "executor": "selenium",
             "scenario": {
                 "script": "tests/selenium/invalid/selenium1.java"
             }
         }
     })
     obj.execution = obj.engine.config['execution']
     obj.prepare()
     obj.startup()
     while not obj.check():
         time.sleep(1)
     obj.shutdown()
     with open(obj.kpi_file) as kpi_fds:
         contents = kpi_fds.read()
     self.assertEqual(contents.count("--TIME:"), 2)
Exemplo n.º 18
0
    def test_selenium_startup_shutdown_jar_folder(self):
        """
        run tests from jars
        :return:
        """
        obj = SeleniumExecutor()
        obj.engine = EngineEmul()
        obj.engine.config.merge(yaml.load(open("tests/yaml/selenium_executor_jar.yml").read()))
        obj.engine.config.merge({"provisioning": "local"})
        obj.execution = obj.engine.config['execution']
        obj.settings.merge(obj.engine.config.get("modules").get("selenium"))
        obj.prepare()
        obj.startup()
        while not obj.check():
            time.sleep(1)
        obj.shutdown()

        prepared_files = os.listdir(obj.runner.working_dir)
        java_files = [file for file in prepared_files if file.endswith(".java")]
        class_files = [file for file in prepared_files if file.endswith(".class")]
        jars = [file for file in prepared_files if file.endswith(".jar")]
        self.assertEqual(len(java_files), 0)
        self.assertEqual(len(class_files), 0)
        self.assertEqual(len(jars), 2)
        self.assertTrue(os.path.exists(obj.runner.report_file))
Exemplo n.º 19
0
 def test_samples_count_testcase(self):
     """
     Test exact number of tests when test class extends JUnit TestCase
     :return:
     """
     obj = SeleniumExecutor()
     obj.engine = EngineEmul()
     obj.engine.config = BetterDict()
     obj.engine.config.merge({
         "execution": {
             "executor": "selenium",
             "scenario": {
                 "script": "tests/selenium/invalid/SimpleTest.java"
             }
         }
     })
     obj.execution = obj.engine.config['execution']
     obj.prepare()
     obj.startup()
     while not obj.check():
         time.sleep(1)
     obj.shutdown()
     with open(obj.kpi_file) as kpi_fds:
         contents = kpi_fds.read()
     self.assertEqual(contents.count("--TIME:"), 2)
Exemplo n.º 20
0
 def test_no_test_in_name(self):
     """
     Test exact number of tests when annotations used and no "test" in class name
     :return:
     """
     obj = SeleniumExecutor()
     obj.engine = self.engine_obj
     obj.settings = self.selenium_config
     obj.engine.config.merge({
         ScenarioExecutor.EXEC: {
             "executor": "selenium",
             "scenario": {
                 "script": __dir__() + "/../selenium/invalid/selenium1.java"
             }
         }
     })
     obj.execution = obj.engine.config['execution']
     obj.prepare()
     obj.startup()
     while not obj.check():
         time.sleep(1)
     obj.shutdown()
     with open(obj.kpi_file) as kpi_fds:
         reader = csv.reader(kpi_fds)
         rows = list(reader)
     self.assertEqual(len(rows), 3)
Exemplo n.º 21
0
 def test_selenium_startup_shutdown_python_folder(self):
     """
     run tests from .py files
     :return:
     """
     obj = SeleniumExecutor()
     obj.engine = EngineEmul()
     obj.engine.config.merge({
         'execution': {
             'scenario': {'script': __dir__() + '/../selenium/python/'},
             'executor': 'selenium'
         },
         'reporting': [{'module': 'junit-xml'}]
     })
     obj.engine.config.merge({"provisioning": "local"})
     obj.execution = obj.engine.config['execution']
     obj.settings.merge(obj.engine.config.get("modules").get("selenium"))
     obj.prepare()
     obj.startup()
     while not obj.check():
         time.sleep(1)
     obj.shutdown()
     prepared_files = os.listdir(obj.runner.working_dir)
     python_files = [fname for fname in prepared_files if fname.endswith(".py")]
     self.assertEqual(2, len(python_files))
     self.assertTrue(os.path.exists(obj.runner.settings.get("report-file")))
Exemplo n.º 22
0
    def test_selenium_startup_shutdown_java_folder(self):
        """
        run tests from .java files
        :return:
        """
        obj = SeleniumExecutor()
        obj.engine = self.engine_obj
        obj.settings = self.selenium_config
        obj.engine.config.merge({'execution': {'scenario': {'script': 'tests/selenium/java/'}, 'executor': 'selenium'},
                                 'reporting': [{'module': 'junit-xml'}]})
        obj.engine.config.merge({"provisioning": "local"})
        obj.execution = obj.engine.config['execution']
        obj.settings.merge(obj.engine.config.get("modules").get("selenium"))
        obj.prepare()
        obj.startup()
        while not obj.check():
            time.sleep(1)
        obj.shutdown()

        prepared_files = os.listdir(obj.runner.working_dir)
        java_files = [file for file in prepared_files if file.endswith(".java")]
        class_files = [file for file in prepared_files if file.endswith(".class")]
        jars = [file for file in prepared_files if file.endswith(".jar")]
        self.assertEqual(2, len(java_files))
        self.assertEqual(2, len(class_files))
        self.assertEqual(1, len(jars))
        self.assertTrue(os.path.exists(os.path.join(obj.runner.working_dir, "compiled.jar")))
        self.assertTrue(os.path.exists(obj.runner.settings.get("report-file")))
Exemplo n.º 23
0
    def test_requests(self):
        obj = SeleniumExecutor()
        obj.engine = self.engine_obj
        obj.settings = self.selenium_config
        obj.engine.config.merge(yaml.load(open(__dir__() + "/../yaml/selenium_executor_requests.yml").read()))
        obj.engine.config.merge({"provisioning": "local"})
        obj.execution = obj.engine.config['execution']

        obj.prepare()
        obj.startup()
        while not obj.check():
            time.sleep(1)
        obj.shutdown()
        with open(os.path.join(obj.engine.artifacts_dir, "junit.err")) as fds:
            contents = fds.read()
            self.assertEqual(1, contents.count("ok"))
            self.assertEqual(1, contents.count("OK"))
Exemplo n.º 24
0
    def test_selenium_startup_shutdown_jar_single(self):
        """
        runt tests from single jar
        :return:
        """
        obj = SeleniumExecutor()
        obj.engine = self.engine_obj
        obj.settings = self.selenium_config
        obj.engine.config.merge({
            'execution': {
                'scenario': {
                    'script': 'tests/selenium/jar/'
                },
                'executor': 'selenium'
            },
            'reporting': [{
                'module': 'junit-xml'
            }]
        })
        obj.engine.config.merge({"provisioning": "local"})
        obj.execution = obj.engine.config['execution']
        obj.execution.merge({
            "scenario": {
                "script": ABS_PATH("/../../tests/selenium/jar/dummy.jar")
            }
        })
        obj.settings.merge(obj.engine.config.get("modules").get("selenium"))
        obj.prepare()
        obj.startup()
        while not obj.check():
            time.sleep(1)
        obj.shutdown()

        prepared_files = os.listdir(obj.runner.working_dir)
        java_files = [
            file for file in prepared_files if file.endswith(".java")
        ]
        class_files = [
            file for file in prepared_files if file.endswith(".class")
        ]
        jars = [file for file in prepared_files if file.endswith(".jar")]
        self.assertEqual(len(java_files), 0)
        self.assertEqual(len(class_files), 0)
        self.assertEqual(len(jars), 1)
        self.assertTrue(os.path.exists(obj.runner.settings.get("report-file")))
Exemplo n.º 25
0
    def test_selenium_startup_shutdown_java_package(self):
        """
        Run tests from package
        :return:
        """
        obj = SeleniumExecutor()
        obj.engine = EngineEmul()
        obj.engine.config.merge(yaml.load(open("tests/yaml/selenium_executor_java_package.yml").read()))
        obj.engine.config.merge({"provisioning": "local"})
        obj.execution = obj.engine.config['execution']

        obj.settings.merge(obj.engine.config.get("modules").get("selenium"))
        obj.prepare()
        obj.startup()
        while not obj.check():
            time.sleep(1)
        obj.shutdown()
        self.assertTrue(os.path.exists(os.path.join(obj.runner.working_dir, "compiled.jar")))
Exemplo n.º 26
0
 def test_samples_count_testcase(self):
     """
     Test exact number of tests when test class extends JUnit TestCase
     :return:
     """
     obj = SeleniumExecutor()
     obj.engine = self.engine_obj
     obj.settings = self.selenium_config
     obj.engine.config.merge({ScenarioExecutor.EXEC: {
         "executor": "selenium",
         "scenario": {"script": __dir__() + "/../selenium/invalid/SimpleTest.java"}
     }})
     obj.execution = obj.engine.config['execution']
     obj.prepare()
     obj.startup()
     while not obj.check():
         time.sleep(1)
     obj.shutdown()
Exemplo n.º 27
0
 def test_samples_count_annotations(self):
     """
     Test exact number of tests when java annotations used
     :return:
     """
     obj = SeleniumExecutor()
     obj.engine = self.engine_obj
     obj.settings = self.selenium_config
     obj.engine.config.merge({ScenarioExecutor.EXEC: {
         "executor": "selenium",
         "scenario": {"script": __dir__() + "/../selenium/invalid/SeleniumTest.java"}
     }})
     obj.execution = obj.engine.config['execution']
     obj.prepare()
     obj.startup()
     while not obj.check():
         time.sleep(1)
     obj.shutdown()
Exemplo n.º 28
0
    def test_requests(self):
        obj = SeleniumExecutor()
        obj.engine = self.engine_obj
        obj.settings = self.selenium_config
        obj.engine.config.merge(yaml.load(open(__dir__() + "/../yaml/selenium_executor_requests.yml").read()))
        obj.engine.config.merge({"provisioning": "local"})
        obj.execution = obj.engine.config['execution']

        obj.prepare()
        obj.get_widget()
        obj.startup()
        while not obj.check():
            time.sleep(1)
        obj.shutdown()
        with open(os.path.join(obj.engine.artifacts_dir, "junit.err")) as fds:
            contents = fds.read()
            self.assertEqual(1, contents.count("ok"))
            self.assertEqual(1, contents.count("OK"))
Exemplo n.º 29
0
 def test_no_test_in_name(self):
     """
     Test exact number of tests when annotations used and no "test" in class name
     :return:
     """
     obj = SeleniumExecutor()
     obj.engine = self.engine_obj
     obj.settings = self.selenium_config
     obj.engine.config.merge({ScenarioExecutor.EXEC: {
         "executor": "selenium",
         "scenario": {"script": __dir__() + "/../selenium/invalid/selenium1.java"}
     }})
     obj.execution = obj.engine.config['execution']
     obj.prepare()
     obj.startup()
     while not obj.check():
         time.sleep(1)
     obj.shutdown()
Exemplo n.º 30
0
    def test_selenium_startup_shutdown_python_single(self):
        """
        run tests from .py file
        :return:
        """

        obj = SeleniumExecutor()
        obj.engine = EngineEmul()
        obj.engine.config = BetterDict()
        obj.engine.config.merge({
            'execution': {
                'scenario': {
                    'script': 'tests/selenium/python/'
                },
                'executor': 'selenium'
            },
            'reporting': [{
                'module': 'junit-xml'
            }]
        })
        obj.engine.config.merge({"provisioning": "local"})
        obj.execution = obj.engine.config['execution']

        obj.execution.merge({
            "scenario": {
                "script":
                ABS_PATH(
                    "/../../tests/selenium/python/test_blazemeter_fail.py")
            }
        })

        obj.settings.merge(obj.engine.config.get("modules").get("selenium"))
        obj.prepare()
        obj.startup()
        while not obj.check():
            time.sleep(1)
        obj.shutdown()
        prepared_files = os.listdir(obj.runner.working_dir)
        python_files = [
            file for file in prepared_files if file.endswith(".py")
        ]
        self.assertEqual(1, len(python_files))
        self.assertTrue(os.path.exists(obj.runner.settings.get("report-file")))
Exemplo n.º 31
0
 def test_not_junit(self):
     """
     Check that JUnit runner fails if no tests were found
     :return:
     """
     obj = SeleniumExecutor()
     obj.engine = EngineEmul()
     obj.engine.config = BetterDict()
     obj.engine.config.merge(
         {"execution": {"executor": "selenium", "scenario": {"script": "tests/selenium/invalid/NotJUnittest.java"}}})
     obj.execution = obj.engine.config['execution']
     obj.prepare()
     obj.startup()
     try:
         while not obj.check():
             time.sleep(1)
     except BaseException as exc:
         self.assertEqual(exc.args[0], "Test runner JunitTester has failed: There is nothing to test.")
     obj.shutdown()
Exemplo n.º 32
0
 def test_samples_count_testcase(self):
     """
     Test exact number of tests when test class extends JUnit TestCase
     :return:
     """
     obj = SeleniumExecutor()
     obj.engine = EngineEmul()
     obj.engine.config = BetterDict()
     obj.engine.config.merge(
         {"execution": {"executor": "selenium", "scenario": {"script": "tests/selenium/invalid/SimpleTest.java"}}})
     obj.execution = obj.engine.config['execution']
     obj.prepare()
     obj.startup()
     while not obj.check():
         time.sleep(1)
     obj.shutdown()
     with open(obj.kpi_file) as kpi_fds:
         contents = kpi_fds.read()
     self.assertEqual(contents.count("--TIME:"), 2)
Exemplo n.º 33
0
 def test_no_test_in_name(self):
     """
     Test exact number of tests when annotations used and no "test" in class name
     :return:
     """
     obj = SeleniumExecutor()
     obj.engine = EngineEmul()
     obj.engine.config = BetterDict()
     obj.engine.config.merge(
         {"execution": {"executor": "selenium", "scenario": {"script": "tests/selenium/invalid/selenium1.java"}}})
     obj.execution = obj.engine.config['execution']
     obj.prepare()
     obj.startup()
     while not obj.check():
         time.sleep(1)
     obj.shutdown()
     with open(obj.kpi_file) as kpi_fds:
         contents = kpi_fds.read()
     self.assertEqual(contents.count("--TIME:"), 2)
Exemplo n.º 34
0
 def runner_fail_no_test_found(self):
     """
     Check that Python Nose runner fails if no tests were found
     :return:
     """
     obj = SeleniumExecutor()
     obj.engine = EngineEmul()
     obj.engine.config = BetterDict()
     obj.engine.config.merge(
         {"execution": {"executor": "selenium", "scenario": {"script": "tests/selenium/invalid/dummy.py"}}})
     obj.execution = obj.engine.config['execution']
     obj.prepare()
     obj.startup()
     try:
         while not obj.check():
             time.sleep(1)
     except BaseException as exc:
         self.assertEqual(exc.args[0], "Test runner NoseTester has failed: Nothing to test.")
     obj.shutdown()
Exemplo n.º 35
0
 def test_selenium_startup_shutdown_java_package(self):
     """
     Run tests from package
     :return:
     """
     obj = SeleniumExecutor()
     obj.engine = self.engine_obj
     obj.settings = self.selenium_config
     obj.engine.config.merge(
         {'execution': {'scenario': {'script': 'tests/selenium/java_package/'}, 'executor': 'selenium'},
          'reporting': [{'module': 'junit-xml'}]})
     obj.engine.config.merge({"provisioning": "local"})
     obj.execution = obj.engine.config['execution']
     obj.settings.merge(obj.engine.config.get("modules").get("selenium"))
     obj.prepare()
     obj.startup()
     while not obj.check():
         time.sleep(1)
     obj.shutdown()
     self.assertTrue(os.path.exists(os.path.join(obj.runner.working_dir, "compiled.jar")))
Exemplo n.º 36
0
 def test_samples_count_testcase(self):
     """
     Test exact number of tests when test class extends JUnit TestCase
     :return:
     """
     obj = SeleniumExecutor()
     obj.engine = self.engine_obj
     obj.settings = self.selenium_config
     obj.engine.config.merge(
         {"execution": {"executor": "selenium", "scenario": {"script": "tests/selenium/invalid/SimpleTest.java"}}})
     obj.execution = obj.engine.config['execution']
     obj.prepare()
     obj.startup()
     while not obj.check():
         time.sleep(1)
     obj.shutdown()
     with open(obj.kpi_file) as kpi_fds:
         reader = csv.reader(kpi_fds)
         rows = list(reader)
     self.assertEqual(len(rows), 3)
Exemplo n.º 37
0
 def test_no_test_in_name(self):
     """
     Test exact number of tests when annotations used and no "test" in class name
     :return:
     """
     obj = SeleniumExecutor()
     obj.engine = self.engine_obj
     obj.settings = self.selenium_config
     obj.engine.config.merge(
         {"execution": {"executor": "selenium", "scenario": {"script": "tests/selenium/invalid/selenium1.java"}}}
     )
     obj.execution = obj.engine.config["execution"]
     obj.prepare()
     obj.startup()
     while not obj.check():
         time.sleep(1)
     obj.shutdown()
     with open(obj.kpi_file) as kpi_fds:
         reader = csv.reader(kpi_fds)
         rows = list(reader)
     self.assertEqual(len(rows), 3)
Exemplo n.º 38
0
 def runner_fail_no_test_found(self):
     """
     Check that Python Nose runner fails if no tests were found
     :return:
     """
     obj = SeleniumExecutor()
     obj.engine = EngineEmul()
     obj.engine.config = BetterDict()
     obj.engine.config.merge(
         {"execution": {"executor": "selenium", "scenario": {"script": "tests/selenium/invalid/dummy.py"}}}
     )
     obj.execution = obj.engine.config["execution"]
     obj.prepare()
     obj.startup()
     try:
         while not obj.check():
             time.sleep(1)
         self.fail()
     except RuntimeError as exc:
         self.assertIn("Nothing to test.", exc.args[0])
     obj.shutdown()
Exemplo n.º 39
0
 def test_samples_count_annotations(self):
     """
     Test exact number of tests when java annotations used
     :return:
     """
     obj = SeleniumExecutor()
     obj.engine = self.engine_obj
     obj.settings = self.selenium_config
     obj.engine.config.merge(
         {ScenarioExecutor.EXEC: {"executor": "selenium",
                                  "scenario": {"script": __dir__() + "/../selenium/invalid/SeleniumTest.java"}}})
     obj.execution = obj.engine.config['execution']
     obj.prepare()
     obj.startup()
     while not obj.check():
         time.sleep(1)
     obj.shutdown()
     with open(obj.kpi_file) as kpi_fds:
         reader = csv.reader(kpi_fds)
         rows = list(reader)
     self.assertEqual(len(rows), 3)
Exemplo n.º 40
0
 def test_not_junit(self):
     """
     Check that JUnit runner fails if no tests were found
     :return:
     """
     obj = SeleniumExecutor()
     obj.engine = self.engine_obj
     obj.settings = self.selenium_config
     obj.engine.config = BetterDict()
     obj.engine.config.merge(
         {"execution": {"executor": "selenium", "scenario": {"script": "tests/selenium/invalid/NotJUnittest.java"}}})
     obj.execution = obj.engine.config['execution']
     obj.prepare()
     obj.startup()
     try:
         while not obj.check():
             time.sleep(1)
         self.fail()
     except BaseException as exc:
         self.assertIn("Nothing to test", exc.args[0])
     obj.shutdown()
Exemplo n.º 41
0
    def test_selenium_startup_shutdown_java_single(self):
        """
        run tests from single .java file
        :return:
        """
        obj = SeleniumExecutor()
        obj.engine = self.engine_obj
        obj.settings = self.selenium_config
        obj.engine.config.merge(
            yaml.load(open("tests/yaml/selenium_executor_java.yml").read()))
        obj.engine.config.merge({"provisioning": "local"})
        obj.execution = obj.engine.config['execution']
        obj.execution.merge({
            "scenario": {
                "script":
                ABS_PATH("/../../tests/selenium/java/TestBlazemeterFail.java")
            }
        })
        obj.settings.merge(obj.engine.config.get("modules").get("selenium"))
        obj.prepare()
        obj.startup()
        while not obj.check():
            time.sleep(1)
        obj.shutdown()

        prepared_files = os.listdir(obj.runner.working_dir)
        java_files = [
            file for file in prepared_files if file.endswith(".java")
        ]
        class_files = [
            file for file in prepared_files if file.endswith(".class")
        ]
        jars = [file for file in prepared_files if file.endswith(".jar")]
        self.assertEqual(1, len(java_files))
        self.assertEqual(1, len(class_files))
        self.assertEqual(1, len(jars))
        self.assertTrue(
            os.path.exists(os.path.join(obj.runner.working_dir,
                                        "compiled.jar")))
        self.assertTrue(os.path.exists(obj.runner.settings.get("report-file")))
Exemplo n.º 42
0
    def test_selenium_startup_shutdown_java_package(self):
        """
        Run tests from package
        :return:
        """
        obj = SeleniumExecutor()
        obj.engine = EngineEmul()
        obj.engine.config.merge(
            yaml.load(
                open("tests/yaml/selenium_executor_java_package.yml").read()))
        obj.engine.config.merge({"provisioning": "local"})
        obj.execution = obj.engine.config['execution']

        obj.settings.merge(obj.engine.config.get("modules").get("selenium"))
        obj.prepare()
        obj.startup()
        while not obj.check():
            time.sleep(1)
        obj.shutdown()
        self.assertTrue(
            os.path.exists(os.path.join(obj.runner.working_dir,
                                        "compiled.jar")))
Exemplo n.º 43
0
    def test_selenium_startup_shutdown_jar_single(self):
        """
        runt tests from single jar
        :return:
        """
        obj = SeleniumExecutor()
        obj.engine = EngineEmul()
        obj.engine.config.merge(
            yaml.load(open("tests/yaml/selenium_executor_jar.yml").read()))
        obj.engine.config.merge({"provisioning": "local"})
        obj.execution = obj.engine.config['execution']
        obj.execution.merge({
            "scenario": {
                "script":
                os.path.abspath(__dir__() +
                                "/../../tests/selenium/jar/dummy.jar")
            }
        })
        obj.settings.merge(obj.engine.config.get("modules").get("selenium"))
        obj.prepare()
        obj.startup()
        while not obj.check():
            time.sleep(1)
        obj.shutdown()

        prepared_files = os.listdir(obj.runner.working_dir)
        java_files = [
            file for file in prepared_files if file.endswith(".java")
        ]
        class_files = [
            file for file in prepared_files if file.endswith(".class")
        ]
        jars = [file for file in prepared_files if file.endswith(".jar")]
        self.assertEqual(len(java_files), 0)
        self.assertEqual(len(class_files), 0)
        self.assertEqual(len(jars), 1)
        self.assertTrue(os.path.exists(obj.runner.report_file))
Exemplo n.º 44
0
 def test_selenium_startup_shutdown_python_folder(self):
     """
     run tests from .py files
     :return:
     """
     obj = SeleniumExecutor()
     obj.engine = EngineEmul()
     obj.engine.config = BetterDict()
     obj.engine.config.merge(
         yaml.load(open("tests/yaml/selenium_executor_python.yml").read()))
     obj.engine.config.merge({"provisioning": "local"})
     obj.execution = obj.engine.config['execution']
     obj.settings.merge(obj.engine.config.get("modules").get("selenium"))
     obj.prepare()
     obj.startup()
     while not obj.check():
         time.sleep(1)
     obj.shutdown()
     prepared_files = os.listdir(obj.runner.working_dir)
     python_files = [
         file for file in prepared_files if file.endswith(".py")
     ]
     self.assertEqual(2, len(python_files))
     self.assertTrue(os.path.exists(obj.runner.settings.get("report-file")))