Skip to content

fix: failing test detection #455

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 8, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions core/base_test/tns_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from products.nativescript.tns import Tns


# noinspection PyBroadException
# noinspection PyBroadException,PyUnresolvedReferences
class TnsTest(unittest.TestCase):
@classmethod
def setUpClass(cls):
Expand Down Expand Up @@ -72,20 +72,21 @@ def tearDown(self):
Gradle.kill()
Process.kill_all_in_context()
TnsTest.restore_files()
# Analise test result
if Settings.PYTHON_VERSION < 3:
# noinspection PyUnresolvedReferences
result = self._resultForDoCleanups
else:
# noinspection PyUnresolvedReferences
result = self._outcome.result

outcome = 'FAILED'
if result.errors == [] and result.failures == []:
outcome = 'PASSED'
else:
# Get outcome
if hasattr(self, '_outcome'): # Python 3.4+
result = self.defaultTestResult() # these 2 methods have no side effects
self._feedErrorsToResult(result, self._outcome.errors)
else: # Python 3.2 - 3.3 or 3.0 - 3.1 and 2.7
result = getattr(self, '_outcomeForDoCleanups', self._resultForDoCleanups)

# Take screen on test fail
if result.errors or result.failures:
self.get_screenshots()
self.archive_apps()
outcome = 'FAILED'
else:
outcome = 'PASSED'
Log.test_end(test_name=TestContext.TEST_NAME, outcome=outcome)

@classmethod
Expand Down Expand Up @@ -113,7 +114,10 @@ def get_screenshots():
try:
import pyautogui
png_path = os.path.join(base_path, 'host.png')
File.delete(png_path)
Folder.create(folder=os.path.dirname(png_path))
pyautogui.screenshot().save(png_path)
Log.info("Saved host os screen at {0}".format(png_path))
except Exception:
Log.warning('Failed to take screenshot of host os.')

Expand Down