Skip to content

Commit 69506eb

Browse files
committed
1 parent a3e3ddc commit 69506eb

8 files changed

+40
-42
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ Install [Python](https://www.python.org/downloads/) 2.7.*
77
Install dependencies
88
```
99
pip install psutil
10-
pip install nose
1110
pip install nose_parameterized
1211
pip install enum34
12+
pip install flaky
1313
pip install uiautomator
1414
pip install Pillow
1515
pip install pytesseract

tests/device/run_android_tests.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
import os
1919

20+
from flaky import flaky
21+
2022
from core.base_class.BaseClass import BaseClass
2123
from core.device.device import Device
2224
from core.device.emulator import Emulator
@@ -60,6 +62,7 @@ def tearDownClass(cls):
6062
BaseClass.tearDownClass()
6163
Emulator.stop()
6264

65+
@flaky(max_runs=2)
6366
def test_001_tns_run_android_js_css_xml(self):
6467
"""Make valid changes in JS,CSS and XML"""
6568

@@ -171,15 +174,17 @@ def test_210_tns_run_android_add_remove_files_and_folders(self):
171174
error_message = 'Deleted folder {0} is still available on {1}'.format(new_folder_name, self.DEVICE_ID)
172175
assert Adb.path_does_not_exist(device_id=self.DEVICE_ID, package_id=app_id, path=path), error_message
173176

177+
@flaky(max_runs=2)
174178
def test_300_tns_run_android_emulator_should_start_emulator_even_if_device_is_connected(self):
175179
"""
176180
`tns run android --emulator` should start emulator even if physical device is connected
177181
"""
178182
Emulator.stop()
179-
output = Tns.run_android(attributes={'--path': self.app_name, '--emulator': '', '--justlaunch': ''},
180-
assert_success=False)
183+
output = Tns.run_android(
184+
attributes={'--path': self.app_name, '--timeout': '180', '--emulator': '', '--justlaunch': ''},
185+
assert_success=False)
181186
assert 'Starting Android emulator with image' in output
182-
assert Emulator.is_running(device_id=EMULATOR_ID), 'Emulator not started by `tns run android`!'
187+
assert Emulator.wait(device_id=EMULATOR_ID), 'Emulator not started by `tns run android`!'
183188

184189
def test_310_tns_run_android_emulator_should_run_only_on_emulator(self):
185190
"""

tests/device/run_ios_tests.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
import os
1919
from time import sleep
2020

21+
from flaky import flaky
22+
2123
from core.base_class.BaseClass import BaseClass
2224
from core.device.device import Device
2325
from core.device.emulator import Emulator
@@ -64,6 +66,7 @@ def tearDownClass(cls):
6466
BaseClass.tearDownClass()
6567
Simulator.stop()
6668

69+
@flaky(max_runs=2)
6770
def test_001_tns_run_ios_js_css_xml(self):
6871
"""Make valid changes in JS,CSS and XML"""
6972

@@ -166,13 +169,14 @@ def test_210_tns_run_ios_add_remove_files_and_folders(self):
166169
strings = ['Successfully transferred test2', 'Successfully transferred test.txt']
167170
Tns.wait_for_log(log_file=log, string_list=strings)
168171

172+
@flaky(max_runs=2)
169173
def test_300_tns_run_ios_emulator_should_start_emulator_even_if_device_is_connected(self):
170174
"""
171175
`tns run ios --emulator` should start emulator even if physical device is connected
172176
"""
173177
Simulator.stop()
174178
Tns.run_ios(attributes={'--path': self.app_name, '--emulator': '', '--justlaunch': ''}, assert_success=False)
175-
assert Simulator.is_running()[0], 'iOS Simulator not started by `tns run ios`!'
179+
assert Simulator.wait_for_simulator()[0], 'iOS Simulator not started by `tns run ios`!'
176180

177181
def test_310_tns_run_ios_emulator_should_run_only_on_emulator(self):
178182
"""

tests/device/run_ios_tests_ng.py

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import os
66
from time import sleep
77

8+
from flaky import flaky
9+
810
from core.base_class.BaseClass import BaseClass
911
from core.device.device import Device
1012
from core.device.emulator import Emulator
@@ -53,6 +55,7 @@ def tearDownClass(cls):
5355
BaseClass.tearDownClass()
5456
Simulator.stop()
5557

58+
@flaky(max_runs=2)
5659
def test_001_tns_run_ios_ts_css_html(self):
5760
"""Make valid changes in JS,CSS and XML"""
5861

tests/emulator/debug_android_tests.py

+14-37
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
"""
44
import os
55

6+
from flaky import flaky
7+
68
from core.base_class.BaseClass import BaseClass
79
from core.device.device import Device
810
from core.device.emulator import Emulator
911
from core.osutils.file import File
1012
from core.osutils.folder import Folder
11-
from core.osutils.process import Process
1213
from core.settings.settings import EMULATOR_NAME, EMULATOR_ID, ANDROID_RUNTIME_PATH
1314
from core.tns.tns import Tns
1415
from core.tns.tns_platform_type import Platform
@@ -38,46 +39,12 @@ def tearDownClass(cls):
3839
BaseClass.tearDownClass()
3940
Emulator.stop()
4041

41-
"""
42-
Spec:
43-
44-
Usage Synopsis
45-
Deploy on device, run the app start Chrome DevTools, and attach the debugger $ tns debug android
46-
Deploy on device, run the app and stop at the first code statement $ tns debug android --debug-brk [--device <Device ID>] [--debug-port <port>] [--timeout <timeout>]
47-
Deploy in the native emulator, run the app and stop at the first code statement $ tns debug android --debug-brk --emulator [<Emulator Options>] [--timeout <timeout>]
48-
Attach the debug tools to a running app on device $ tns debug android --start [--device <Device ID>] [--debug-port <port>] [--timeout <timeout>]
49-
Attach the debug tools to a running app in the native emulator $ tns debug android --start --emulator [<Emulator Options>] [--timeout <timeout>]
50-
Detach the debug tools $ tns debug android --stop
51-
52-
53-
Prepares, builds and deploys the project when necessary. Debugs your project on a connected device or emulator.
54-
While debugging, prints the output from the application in the console and watches for changes in your code. Once a change is detected, it synchronizes the change with all selected devices and restarts/refreshes the application.
55-
56-
### Options
57-
58-
* --device - Specifies a connected device on which to debug the app.
59-
* --emulator - Specifies that you want to debug the app in the native Android emulator from the Android SDK.
60-
* --debug-brk - Prepares, builds and deploys the application package on a device or in an emulator, launches the Chrome DevTools of your Chrome browser and stops at the first code statement.
61-
* --start - Attaches the debug tools to a deployed and running app.
62-
* --stop - Detaches the debug tools.
63-
* --debug-port - Sets a new port on which to attach the debug tools.
64-
* --timeout - Sets the number of seconds that the NativeScript CLI will wait for the debugger to boot. If not set, the default timeout is 90 seconds.
65-
* --no-watch - If set, changes in your code will not be reflected during the execution of this command.
66-
* --clean - If set, forces rebuilding the native application.
67-
68-
### Attributes
69-
70-
* <Device ID> is the index or name of the target device as listed by $ tns device
71-
* <Port> is an accessible port on the device to which you want to attach the debugging tools.
72-
* <Emulator Options> is any valid combination of options as listed by $ tns help emulate android
73-
"""
74-
7542
def __verify_debugger_start(self, log):
7643
strings = [EMULATOR_ID, 'NativeScript Debugger started', 'To start debugging, open the following URL in Chrome',
7744
'chrome-devtools', 'localhost:40000']
7845
if Device.get_count(platform=Platform.ANDROID) > 0:
7946
strings.append("Multiple devices found! Starting debugger on emulator")
80-
Tns.wait_for_log(log_file=log, string_list=strings, timeout=120, check_interval=10, clean_log=False)
47+
Tns.wait_for_log(log_file=log, string_list=strings, timeout=180, check_interval=10, clean_log=False)
8148
output = File.read(file_path=log, print_content=True)
8249
assert "closed" not in output
8350
assert "detached" not in output
@@ -87,7 +54,7 @@ def __verify_debugger_attach(self, log):
8754
strings = [EMULATOR_ID, 'To start debugging', 'Chrome', 'chrome-devtools', 'localhost:40000']
8855
if Device.get_count(platform=Platform.ANDROID) > 0:
8956
strings.append("Multiple devices found! Starting debugger on emulator")
90-
Tns.wait_for_log(log_file=log, string_list=strings, timeout=120, check_interval=10, clean_log=False)
57+
Tns.wait_for_log(log_file=log, string_list=strings, timeout=180, check_interval=10, clean_log=False)
9158
output = File.read(file_path=log, print_content=True)
9259
assert "closed" not in output
9360
assert "detached" not in output
@@ -131,3 +98,13 @@ def test_003_debug_android_emulator_start(self):
13198
# Attach debugger
13299
log = Tns.debug_android(attributes={'--path': self.app_name, '--start': ''})
133100
self.__verify_debugger_attach(log=log)
101+
102+
@flaky(max_runs=2)
103+
def test_100_debug_android_should_start_emulator_if_there_is_no_device(self):
104+
"""
105+
Debug android should start emulator if emulator is not running
106+
"""
107+
108+
Emulator.stop()
109+
Tns.debug_android(attributes={'--path': self.app_name, '--emulator': '', '--timeout': '180'})
110+
assert Emulator.wait(device_id=EMULATOR_ID)

tests/emulator/run_android_tests.py

+3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import unittest
1717

1818
import nose
19+
from flaky import flaky
1920

2021
from core.base_class.BaseClass import BaseClass
2122
from core.device.device import Device
@@ -61,6 +62,7 @@ def tearDownClass(cls):
6162
BaseClass.tearDownClass()
6263
Emulator.stop() # We need this because of test_400_tns_run_android_respect_adb_errors
6364

65+
@flaky(max_runs=2)
6466
def test_001_tns_run_android_js_css_xml_manifest(self):
6567
"""Make valid changes in JS,CSS and XML"""
6668

@@ -395,6 +397,7 @@ def test_330_tns_run_android_sync_all_files(self):
395397
Device.screen_match(device_name=EMULATOR_NAME, device_id=EMULATOR_ID,
396398
expected_image='livesync-hello-world_home')
397399

400+
@flaky(max_runs=2)
398401
def test_340_tns_run_should_not_sync_hidden_files(self):
399402
"""
400403
Adding hidden files should not break run and they should not be transferred.

tests/simulator/debug_ios_tests.py

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import os
55
import time
66

7+
from flaky import flaky
8+
79
from core.base_class.BaseClass import BaseClass
810
from core.device.device import Device
911
from core.device.emulator import Emulator
@@ -116,6 +118,7 @@ def test_003_debug_ios_simulator_start(self):
116118
log = Tns.debug_ios(attributes={'--path': self.app_name, '--emulator': '', '--start': ''})
117119
self.__verify_debugger_attach(log=log)
118120

121+
@flaky(max_runs=2)
119122
def test_100_debug_ios_simulator_with_livesync(self):
120123
"""
121124
`tns debug ios` should be able to run with livesync

tests/simulator/run_ios_tests.py

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import time
1616

1717
import nose
18+
from flaky import flaky
1819

1920
from core.base_class.BaseClass import BaseClass
2021
from core.device.device import Device
@@ -59,6 +60,7 @@ def tearDownClass(cls):
5960
BaseClass.tearDownClass()
6061
Emulator.stop()
6162

63+
@flaky(max_runs=2)
6264
def test_001_tns_run_ios_js_css_xml(self):
6365
"""Make valid changes in JS,CSS and XML"""
6466

@@ -261,6 +263,7 @@ def test_330_tns_run_ios_sync_all_files(self):
261263
Device.screen_match(device_name=SIMULATOR_NAME, device_id=self.SIMULATOR_ID,
262264
expected_image='livesync-hello-world_home')
263265

266+
@flaky(max_runs=2)
264267
def test_340_tns_run_should_not_sync_hidden_files(self):
265268
"""
266269
Adding hidden files should not break run and they should not be transferred.

0 commit comments

Comments
 (0)