def startTest(self, test):
     """ At the start of the test, set the testcase details. """
     data_payload = TestcaseDataPayload()
     self.testcase_guid = str(uuid.uuid4())
     data_payload.guid = self.testcase_guid
     data_payload.execution_guid = self.execution_guid
     if hasattr(test, "browser"):
         data_payload.browser = test.browser
     else:
         data_payload.browser = "N/A"
     data_payload.test_address = test.id()
     application = ApplicationManager.generate_application_string(test)
     data_payload.env = application.split('.')[0]
     data_payload.start_time = application.split('.')[1]
     data_payload.state = constants.State.NOTRUN
     self.testcase_manager.insert_testcase_data(data_payload)
     self.case_start_time = int(time.time() * 1000)
     # Make the testcase guid available to other plugins
     test.testcase_guid = self.testcase_guid
Пример #2
0
 def startTest(self, test):
     """At the start of the test, set the testcase details."""
     data_payload = TestcaseDataPayload()
     self.testcase_guid = str(uuid.uuid4())
     data_payload.guid = self.testcase_guid
     data_payload.execution_guid = self.execution_guid
     if hasattr(test, "browser"):
         data_payload.browser = test.browser
     else:
         data_payload.browser = "N/A"
     data_payload.testcaseAddress = test.id()
     application = ApplicationManager.generate_application_string(test)
     data_payload.env = application.split('.')[0]
     data_payload.start_time = application.split('.')[1]
     data_payload.state = constants.State.NOTRUN
     self.testcase_manager.insert_testcase_data(data_payload)
     self.case_start_time = int(time.time() * 1000)
     # Make the testcase guid available to other plugins
     test.testcase_guid = self.testcase_guid
Пример #3
0
 def setUp(self):
     """
     pytest-specific code
     Be careful if a subclass of BaseCase overrides setUp()
     You'll need to add the following line to the subclass setUp() method:
     super(SubClassOfBaseCase, self).setUp()
     """
     self.is_pytest = None
     try:
         # This raises an exception if the test is not coming from pytest
         self.is_pytest = pytest.config.option.is_pytest
     except Exception:
         # Not using pytest (probably nosetests)
         self.is_pytest = False
     if self.is_pytest:
         test_id = "%s.%s.%s" % (self.__class__.__module__,
                                 self.__class__.__name__,
                                 self._testMethodName)
         self.with_selenium = pytest.config.option.with_selenium
         self.headless = pytest.config.option.headless
         self.headless_active = False
         self.with_testing_base = pytest.config.option.with_testing_base
         self.with_db_reporting = pytest.config.option.with_db_reporting
         self.with_s3_logging = pytest.config.option.with_s3_logging
         self.with_screen_shots = pytest.config.option.with_screen_shots
         self.with_basic_test_info = (
             pytest.config.option.with_basic_test_info)
         self.with_page_source = pytest.config.option.with_page_source
         self.database_env = pytest.config.option.database_env
         self.log_path = pytest.config.option.log_path
         self.browser = pytest.config.option.browser
         self.data = pytest.config.option.data
         self.demo_mode = pytest.config.option.demo_mode
         self.demo_sleep = pytest.config.option.demo_sleep
         if self.with_db_reporting:
             self.execution_guid = str(uuid.uuid4())
             self.testcase_guid = None
             self.execution_start_time = 0
             self.case_start_time = 0
             self.application = None
             self.testcase_manager = None
             self.error_handled = False
             self.testcase_manager = TestcaseManager(self.database_env)
             #
             exec_payload = ExecutionQueryPayload()
             exec_payload.execution_start_time = int(time.time() * 1000)
             self.execution_start_time = exec_payload.execution_start_time
             exec_payload.guid = self.execution_guid
             exec_payload.username = getpass.getuser()
             self.testcase_manager.insert_execution_data(exec_payload)
             #
             data_payload = TestcaseDataPayload()
             self.testcase_guid = str(uuid.uuid4())
             data_payload.guid = self.testcase_guid
             data_payload.execution_guid = self.execution_guid
             if self.with_selenium:
                 data_payload.browser = self.browser
             else:
                 data_payload.browser = "N/A"
             data_payload.testcaseAddress = test_id
             application = ApplicationManager.generate_application_string(
                 self._testMethodName)
             data_payload.env = application.split('.')[0]
             data_payload.start_time = application.split('.')[1]
             data_payload.state = constants.State.NOTRUN
             self.testcase_manager.insert_testcase_data(data_payload)
             self.case_start_time = int(time.time() * 1000)
         if self.headless:
             self.display = Display(visible=0, size=(1200, 800))
             self.display.start()
             self.headless_active = True
         if self.with_selenium:
             self.driver = browser_launcher.get_driver(self.browser)
Пример #4
0
 def setUp(self):
     """
     pytest-specific code
     Be careful if a subclass of BaseCase overrides setUp()
     You'll need to add the following line to the subclass setUp() method:
     super(SubClassOfBaseCase, self).setUp()
     """
     self.is_pytest = None
     try:
         # This raises an exception if the test is not coming from pytest
         self.is_pytest = pytest.config.option.is_pytest
     except Exception:
         # Not using pytest (probably nosetests)
         self.is_pytest = False
     if self.is_pytest:
         test_id = "%s.%s.%s" % (self.__class__.__module__,
                                 self.__class__.__name__,
                                 self._testMethodName)
         self.with_selenium = pytest.config.option.with_selenium
         self.headless = pytest.config.option.headless
         self.headless_active = False
         self.with_testing_base = pytest.config.option.with_testing_base
         self.with_db_reporting = pytest.config.option.with_db_reporting
         self.with_s3_logging = pytest.config.option.with_s3_logging
         self.with_screen_shots = pytest.config.option.with_screen_shots
         self.with_basic_test_info = (
             pytest.config.option.with_basic_test_info)
         self.with_page_source = pytest.config.option.with_page_source
         self.database_env = pytest.config.option.database_env
         self.log_path = pytest.config.option.log_path
         self.browser = pytest.config.option.browser
         self.data = pytest.config.option.data
         self.demo_mode = pytest.config.option.demo_mode
         self.demo_sleep = pytest.config.option.demo_sleep
         if self.with_db_reporting:
             self.execution_guid = str(uuid.uuid4())
             self.testcase_guid = None
             self.execution_start_time = 0
             self.case_start_time = 0
             self.application = None
             self.testcase_manager = None
             self.error_handled = False
             self.testcase_manager = TestcaseManager(self.database_env)
             #
             exec_payload = ExecutionQueryPayload()
             exec_payload.execution_start_time = int(time.time() * 1000)
             self.execution_start_time = exec_payload.execution_start_time
             exec_payload.guid = self.execution_guid
             exec_payload.username = getpass.getuser()
             self.testcase_manager.insert_execution_data(exec_payload)
             #
             data_payload = TestcaseDataPayload()
             self.testcase_guid = str(uuid.uuid4())
             data_payload.guid = self.testcase_guid
             data_payload.execution_guid = self.execution_guid
             if self.with_selenium:
                 data_payload.browser = self.browser
             else:
                 data_payload.browser = "N/A"
             data_payload.testcaseAddress = test_id
             application = ApplicationManager.generate_application_string(
                 self._testMethodName)
             data_payload.env = application.split('.')[0]
             data_payload.start_time = application.split('.')[1]
             data_payload.state = constants.State.NOTRUN
             self.testcase_manager.insert_testcase_data(data_payload)
             self.case_start_time = int(time.time() * 1000)
         if self.headless:
             self.display = Display(visible=0, size=(1200, 800))
             self.display.start()
             self.headless_active = True
         if self.with_selenium:
             self.driver = browser_launcher.get_driver(self.browser)