Skip to content

Commit d232718

Browse files
committed
fix: DebugiOSInspectorSimulatorTests
- Refactor tests and fix `test_003_debug_ios_simulator_start`
1 parent 8a29895 commit d232718

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

tests/simulator/debug_ios_inspector_tests.py

+16-18
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ def setUpClass(cls):
3838
update_modules=True)
3939
Tns.platform_add_ios(attributes={'--path': cls.app_name, '--frameworkPath': IOS_PACKAGE})
4040
Npm.install(package=IOS_INSPECTOR_PACKAGE, option='--save-dev', folder=cls.app_name)
41+
Tns.build_ios(attributes={"--path": cls.app_name})
4142

4243
def setUp(self):
4344
BaseClass.setUp(self)
@@ -56,33 +57,27 @@ def tearDownClass(cls):
5657
BaseClass.tearDownClass()
5758
Folder.cleanup(cls.app_name)
5859

59-
def __verify_debugger_start(self, log):
60+
@staticmethod
61+
def __verify_debugger_attach(log, app_started=True):
6062
strings = ["Frontend client connected", "Backend socket created", "NativeScript debugger attached"]
61-
Tns.wait_for_log(log_file=log, string_list=strings, timeout=120, check_interval=10, clean_log=False)
63+
Tns.wait_for_log(log_file=log, string_list=strings, timeout=90, check_interval=10, clean_log=False)
6264
time.sleep(10)
6365
output = File.read(log)
6466
assert "Frontend socket closed" not in output
6567
assert "Backend socket closed" not in output
6668
assert "NativeScript debugger detached" not in output
6769
assert Process.is_running('NativeScript Inspector')
68-
69-
def __verify_debugger_attach(self, log):
70-
strings = ["Frontend client connected", "Backend socket created"]
71-
Tns.wait_for_log(log_file=log, string_list=strings, timeout=120, check_interval=10, clean_log=False)
72-
time.sleep(10)
73-
output = File.read(log)
74-
assert "NativeScript debugger attached" not in output # This is not in output when you attach to running app
75-
assert "Frontend socket closed" not in output
76-
assert "Backend socket closed" not in output
77-
assert "NativeScript debugger detached" not in output
78-
assert Process.is_running('NativeScript Inspector')
70+
if app_started:
71+
assert "Page loaded 1 time" in output, "Page not reloaded, this is bug!"
72+
else:
73+
assert "Page loaded 1 time" not in output, "Page reloaded, this is bug!"
7974

8075
def test_001_debug_ios_simulator(self):
8176
"""
8277
Default `tns debug ios` starts debugger (do not stop at the first code statement)
8378
"""
8479
log = Tns.debug_ios(attributes={'--path': self.app_name, '--emulator': '', '--inspector': ''})
85-
self.__verify_debugger_start(log)
80+
DebugiOSInspectorSimulatorTests.__verify_debugger_attach(log)
8681

8782
# Verify app starts and do not stop on first line of code
8883
Device.screen_match(device_name=SIMULATOR_NAME,
@@ -95,7 +90,9 @@ def test_002_debug_ios_simulator_debug_brk(self):
9590

9691
log = Tns.debug_ios(
9792
attributes={'--path': self.app_name, '--emulator': '', '--debug-brk': '', '--inspector': ''})
98-
self.__verify_debugger_start(log)
93+
DebugiOSInspectorSimulatorTests.__verify_debugger_attach(log, app_started=False)
94+
# In this case `app_started` is False because app is not loaded when using '--debug-brk'.
95+
# '--debug-brk' stops before app loaded.
9996

10097
# Verify app starts and do not stop on first line of code
10198
Device.screen_match(device_name=SIMULATOR_NAME, tolerance=3.0, device_id=self.SIMULATOR_ID,
@@ -107,22 +104,23 @@ def test_003_debug_ios_simulator_start(self):
107104
"""
108105

109106
# Run the app and ensure it works
110-
log = Tns.run_ios(attributes={'--path': self.app_name, '--emulator': '', '--justlaunch': '', '--inspector': ''},
107+
log = Tns.run_ios(attributes={'--path': self.app_name, '--emulator': '', '--justlaunch': ''},
111108
assert_success=False, timeout=30)
112109
TnsAsserts.prepared(app_name=self.app_name, platform=Platform.IOS, output=log, prepare=Prepare.SKIP)
113110
Device.screen_match(device_name=SIMULATOR_NAME, device_id=self.SIMULATOR_ID,
114111
expected_image='livesync-hello-world_home')
115112

116113
# Attach debugger
117114
log = Tns.debug_ios(attributes={'--path': self.app_name, '--emulator': '', '--start': '', '--inspector': ''})
118-
self.__verify_debugger_attach(log=log)
115+
DebugiOSInspectorSimulatorTests.__verify_debugger_attach(log, app_started=False)
116+
# In this case `app_started` is False because we are attaching to running app and we should not restart it.
119117

120118
def test_100_debug_ios_simulator_with_livesync(self):
121119
"""
122120
`tns debug ios` should be able to run with livesync
123121
"""
124122
log = Tns.debug_ios(attributes={'--path': self.app_name, '--emulator': '', '--inspector': ''})
125-
self.__verify_debugger_start(log)
123+
DebugiOSInspectorSimulatorTests.__verify_debugger_attach(log)
126124

127125
# Verify app starts and do not stop on first line of code
128126
Device.screen_match(device_name=SIMULATOR_NAME,

0 commit comments

Comments
 (0)