From f02fb0b9d16c760b6d0fd3468fd53c1d0e42e46f Mon Sep 17 00:00:00 2001 From: Nitin Issac Joy Date: Mon, 22 Jul 2019 00:01:22 -0700 Subject: [PATCH] Updating python functional tests to print error to console if any (#188) * Functional test adding logs * Review comments --- .../Tests/functional_tests/test_functional.py | 7 +++---- .../Tests/functional_tests/test_functional.py | 7 +++---- .../Tests/functional_tests/test_functional.py | 7 +++---- .../Tests/functional_tests/test_functional.py | 7 +++---- .../Tests/functional_tests/test_functional.py | 7 +++---- .../Tests/functional_tests/test_functional.py | 7 +++---- 6 files changed, 18 insertions(+), 24 deletions(-) diff --git a/python/bottle/containerWithTests/Tests/functional_tests/test_functional.py b/python/bottle/containerWithTests/Tests/functional_tests/test_functional.py index 5a3d819aa..222a9bc58 100644 --- a/python/bottle/containerWithTests/Tests/functional_tests/test_functional.py +++ b/python/bottle/containerWithTests/Tests/functional_tests/test_functional.py @@ -12,7 +12,7 @@ def setUp(self): options = webdriver.ChromeOptions() options.add_argument('--no-sandbox') self.driver = webdriver.Chrome(os.path.join(os.environ["ChromeWebDriver"], 'chromedriver.exe'), chrome_options=options) - self.driver.implicitly_wait(120) + self.driver.implicitly_wait(300) def test_selenium(self): webAppUrl = pytest.config.getoption('webAppUrl') @@ -24,13 +24,12 @@ def test_selenium(self): title = self.driver.title self.assertIn("Home Page - Python Bottle Application", title) break - except AssertionError: + except Exception as e: current_timestamp = time.time() if(current_timestamp > end_timestamp): + print('"##vso[task.logissue type=error;]Test test_selenium failed with error: ' + str(e)) raise time.sleep(5) - except Exception as e: - pytest.fail('tests_selenium.Error occurred while executing tests: ' + str(e)) def tearDown(self): try: diff --git a/python/bottle/webappWithTests/Tests/functional_tests/test_functional.py b/python/bottle/webappWithTests/Tests/functional_tests/test_functional.py index 5a3d819aa..222a9bc58 100644 --- a/python/bottle/webappWithTests/Tests/functional_tests/test_functional.py +++ b/python/bottle/webappWithTests/Tests/functional_tests/test_functional.py @@ -12,7 +12,7 @@ def setUp(self): options = webdriver.ChromeOptions() options.add_argument('--no-sandbox') self.driver = webdriver.Chrome(os.path.join(os.environ["ChromeWebDriver"], 'chromedriver.exe'), chrome_options=options) - self.driver.implicitly_wait(120) + self.driver.implicitly_wait(300) def test_selenium(self): webAppUrl = pytest.config.getoption('webAppUrl') @@ -24,13 +24,12 @@ def test_selenium(self): title = self.driver.title self.assertIn("Home Page - Python Bottle Application", title) break - except AssertionError: + except Exception as e: current_timestamp = time.time() if(current_timestamp > end_timestamp): + print('"##vso[task.logissue type=error;]Test test_selenium failed with error: ' + str(e)) raise time.sleep(5) - except Exception as e: - pytest.fail('tests_selenium.Error occurred while executing tests: ' + str(e)) def tearDown(self): try: diff --git a/python/django/containerWithTests/Tests/functional_tests/test_functional.py b/python/django/containerWithTests/Tests/functional_tests/test_functional.py index 3f36f9684..551c0dab9 100644 --- a/python/django/containerWithTests/Tests/functional_tests/test_functional.py +++ b/python/django/containerWithTests/Tests/functional_tests/test_functional.py @@ -12,7 +12,7 @@ def setUp(self): options = webdriver.ChromeOptions() options.add_argument('--no-sandbox') self.driver = webdriver.Chrome(os.path.join(os.environ["ChromeWebDriver"], 'chromedriver.exe'), chrome_options=options) - self.driver.implicitly_wait(120) + self.driver.implicitly_wait(300) def test_selenium(self): webAppUrl = pytest.config.getoption('webAppUrl') @@ -24,13 +24,12 @@ def test_selenium(self): title = self.driver.title self.assertIn("Home Page - Python Django Application", title) break - except AssertionError: + except Exception as e: + print('"##vso[task.logissue type=error;]Test test_selenium failed with error: ' + str(e)) current_timestamp = time.time() if(current_timestamp > end_timestamp): raise time.sleep(5) - except Exception as e: - pytest.fail('tests_selenium.Error occurred while executing tests: ' + str(e)) def tearDown(self): try: diff --git a/python/django/webappWithTests/Tests/functional_tests/test_functional.py b/python/django/webappWithTests/Tests/functional_tests/test_functional.py index 3f36f9684..551c0dab9 100644 --- a/python/django/webappWithTests/Tests/functional_tests/test_functional.py +++ b/python/django/webappWithTests/Tests/functional_tests/test_functional.py @@ -12,7 +12,7 @@ def setUp(self): options = webdriver.ChromeOptions() options.add_argument('--no-sandbox') self.driver = webdriver.Chrome(os.path.join(os.environ["ChromeWebDriver"], 'chromedriver.exe'), chrome_options=options) - self.driver.implicitly_wait(120) + self.driver.implicitly_wait(300) def test_selenium(self): webAppUrl = pytest.config.getoption('webAppUrl') @@ -24,13 +24,12 @@ def test_selenium(self): title = self.driver.title self.assertIn("Home Page - Python Django Application", title) break - except AssertionError: + except Exception as e: + print('"##vso[task.logissue type=error;]Test test_selenium failed with error: ' + str(e)) current_timestamp = time.time() if(current_timestamp > end_timestamp): raise time.sleep(5) - except Exception as e: - pytest.fail('tests_selenium.Error occurred while executing tests: ' + str(e)) def tearDown(self): try: diff --git a/python/flask/containerWithTests/Tests/functional_tests/test_functional.py b/python/flask/containerWithTests/Tests/functional_tests/test_functional.py index 5a5bacf77..211ad7318 100644 --- a/python/flask/containerWithTests/Tests/functional_tests/test_functional.py +++ b/python/flask/containerWithTests/Tests/functional_tests/test_functional.py @@ -12,7 +12,7 @@ def setUp(self): options = webdriver.ChromeOptions() options.add_argument('--no-sandbox') self.driver = webdriver.Chrome(os.path.join(os.environ["ChromeWebDriver"], 'chromedriver.exe'), chrome_options=options) - self.driver.implicitly_wait(120) + self.driver.implicitly_wait(300) def test_selenium(self): webAppUrl = pytest.config.getoption('webAppUrl') @@ -24,13 +24,12 @@ def test_selenium(self): title = self.driver.title self.assertIn("Home Page - Python Flask Application", title) break - except AssertionError: + except Exception as e: + print('"##vso[task.logissue type=error;]Test test_selenium failed with error: ' + str(e)) current_timestamp = time.time() if(current_timestamp > end_timestamp): raise time.sleep(5) - except Exception as e: - pytest.fail('tests_selenium.Error occurred while executing tests: ' + str(e)) def tearDown(self): try: diff --git a/python/flask/webappWithTests/Tests/functional_tests/test_functional.py b/python/flask/webappWithTests/Tests/functional_tests/test_functional.py index 5a5bacf77..211ad7318 100644 --- a/python/flask/webappWithTests/Tests/functional_tests/test_functional.py +++ b/python/flask/webappWithTests/Tests/functional_tests/test_functional.py @@ -12,7 +12,7 @@ def setUp(self): options = webdriver.ChromeOptions() options.add_argument('--no-sandbox') self.driver = webdriver.Chrome(os.path.join(os.environ["ChromeWebDriver"], 'chromedriver.exe'), chrome_options=options) - self.driver.implicitly_wait(120) + self.driver.implicitly_wait(300) def test_selenium(self): webAppUrl = pytest.config.getoption('webAppUrl') @@ -24,13 +24,12 @@ def test_selenium(self): title = self.driver.title self.assertIn("Home Page - Python Flask Application", title) break - except AssertionError: + except Exception as e: + print('"##vso[task.logissue type=error;]Test test_selenium failed with error: ' + str(e)) current_timestamp = time.time() if(current_timestamp > end_timestamp): raise time.sleep(5) - except Exception as e: - pytest.fail('tests_selenium.Error occurred while executing tests: ' + str(e)) def tearDown(self): try: