Skip to content

Commit 000a42d

Browse files
authored
feat: migrate regression tests (#29)
Migrate regression tests: https://github.com/NativeScript/nativescript-cli-tests/tree/master/tests/regression Changes that happened during migration: - Tests backward compatiblity with 4.2 (instead of 4.1) - Generate 4.2 app with CLI under test (do not bring old project with tests).
1 parent 929d99c commit 000a42d

File tree

4 files changed

+136
-6
lines changed

4 files changed

+136
-6
lines changed

data/legacy_app.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import os
2+
3+
from core.enums.app_type import AppType
4+
from core.enums.os_type import OSType
5+
from core.settings import Settings
6+
from core.utils.npm import Npm
7+
from products.nativescript.app import App
8+
from products.nativescript.tns import Tns
9+
10+
11+
class LegacyApp(object):
12+
@staticmethod
13+
def create(app_name, app_type):
14+
"""
15+
Create hello-world app based on {N} 4.2
16+
:param app_name: App name.
17+
:param app_type: AppType enum value.
18+
"""
19+
template = 'tns-template-hello-world'
20+
if app_type == AppType.NG:
21+
template = template + '-ng'
22+
if app_type == AppType.TS:
23+
template = template + '-ts'
24+
Tns.create(app_name=app_name, template='{0}@4.2'.format(template), update=False, verify=False)
25+
assert '~4.2.' in App.get_package_json(app_name=app_name).get('dependencies').get('tns-core-modules')
26+
if app_type == AppType.NG:
27+
assert '~6.1.' in App.get_package_json(app_name=app_name).get('dependencies').get('nativescript-angular')
28+
assert '~6.1.' in App.get_package_json(app_name=app_name).get('dependencies').get('@angular/core')
29+
# Add platforms
30+
Tns.platform_add_android(app_name=app_name, version='4.2')
31+
if Settings.HOST_OS == OSType.OSX:
32+
Tns.platform_add_ios(app_name=app_name, version='4.2')
33+
# Install webpack
34+
Npm.install(package='[email protected]', option='--save-dev',
35+
folder=os.path.join(Settings.TEST_RUN_HOME, app_name))
36+
Npm.install(folder=os.path.join(Settings.TEST_RUN_HOME, app_name))
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import unittest
2+
3+
from core.base_test.tns_test import TnsTest
4+
from core.enums.app_type import AppType
5+
from core.enums.os_type import OSType
6+
from core.enums.platform_type import Platform
7+
from core.settings import Settings
8+
from core.utils.device.device_manager import DeviceManager
9+
from data.legacy_app import LegacyApp
10+
from data.sync.hello_world_js import sync_hello_world_js
11+
from products.nativescript.tns import Tns
12+
13+
14+
class JSRegressionTests(TnsTest):
15+
emu = None
16+
sim = None
17+
js_app = Settings.AppName.DEFAULT + 'JS'
18+
19+
@classmethod
20+
def setUpClass(cls):
21+
TnsTest.setUpClass()
22+
23+
# Boot emulator and simulator
24+
cls.emu = DeviceManager.Emulator.ensure_available(Settings.Emulators.DEFAULT)
25+
if Settings.HOST_OS == OSType.OSX:
26+
cls.sim = DeviceManager.Simulator.ensure_available(Settings.Simulators.DEFAULT)
27+
28+
# Create legacy JS app
29+
LegacyApp.create(app_name=cls.js_app, app_type=AppType.JS)
30+
31+
def setUp(self):
32+
TnsTest.setUp(self)
33+
34+
@classmethod
35+
def tearDownClass(cls):
36+
TnsTest.tearDownClass()
37+
38+
def test_100_run_android(self):
39+
sync_hello_world_js(app_name=self.js_app, platform=Platform.ANDROID, device=self.emu)
40+
41+
@unittest.skipIf(Settings.HOST_OS != OSType.OSX, 'iOS tests can be executed only on macOS.')
42+
def test_101_run_ios(self):
43+
sync_hello_world_js(app_name=self.js_app, platform=Platform.IOS, device=self.sim)
44+
45+
def test_200_build_android_release(self):
46+
Tns.build_android(app_name=self.js_app, release=True, bundle=True, aot=True, uglify=True, snapshot=True)
47+
48+
@unittest.skipIf(Settings.HOST_OS != OSType.OSX, 'iOS tests can be executed only on macOS.')
49+
def test_201_build_ios_release(self):
50+
Tns.build_ios(app_name=self.js_app, release=True, for_device=True, bundle=True, aot=True, uglify=True)
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import unittest
2+
3+
from core.base_test.tns_test import TnsTest
4+
from core.enums.app_type import AppType
5+
from core.enums.os_type import OSType
6+
from core.enums.platform_type import Platform
7+
from core.settings import Settings
8+
from core.utils.device.device_manager import DeviceManager
9+
from data.legacy_app import LegacyApp
10+
from data.sync.hello_world_ng import sync_hello_world_ng
11+
from products.nativescript.tns import Tns
12+
13+
14+
class NGRegressionTests(TnsTest):
15+
emu = None
16+
sim = None
17+
ng_app = Settings.AppName.DEFAULT + 'NG'
18+
19+
@classmethod
20+
def setUpClass(cls):
21+
TnsTest.setUpClass()
22+
23+
# Boot emulator and simulator
24+
cls.emu = DeviceManager.Emulator.ensure_available(Settings.Emulators.DEFAULT)
25+
if Settings.HOST_OS == OSType.OSX:
26+
cls.sim = DeviceManager.Simulator.ensure_available(Settings.Simulators.DEFAULT)
27+
28+
# Create legacy NG app
29+
LegacyApp.create(app_name=cls.ng_app, app_type=AppType.NG)
30+
31+
def setUp(self):
32+
TnsTest.setUp(self)
33+
34+
@classmethod
35+
def tearDownClass(cls):
36+
TnsTest.tearDownClass()
37+
38+
def test_100_run_android(self):
39+
sync_hello_world_ng(app_name=self.ng_app, platform=Platform.ANDROID, device=self.emu)
40+
41+
@unittest.skipIf(Settings.HOST_OS != OSType.OSX, 'iOS tests can be executed only on macOS.')
42+
def test_101_run_ios(self):
43+
sync_hello_world_ng(app_name=self.ng_app, platform=Platform.IOS, device=self.sim)
44+
45+
def test_200_build_android_release(self):
46+
Tns.build_android(app_name=self.ng_app, release=True, bundle=True, aot=True, uglify=True, snapshot=True)
47+
48+
@unittest.skipIf(Settings.HOST_OS != OSType.OSX, 'iOS tests can be executed only on macOS.')
49+
def test_201_build_ios_release(self):
50+
Tns.build_ios(app_name=self.ng_app, release=True, for_device=True, bundle=True, aot=True, uglify=True)

tests/cli/smoke/smoke_tests.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import os
21
import unittest
32

43
from core.base_test.tns_test import TnsTest
@@ -14,12 +13,7 @@
1413

1514
class SmokeTests(TnsTest):
1615
js_app = Settings.AppName.DEFAULT + 'JS'
17-
js_source_project_dir = os.path.join(Settings.TEST_RUN_HOME, js_app)
18-
js_target_project_dir = os.path.join(Settings.TEST_RUN_HOME, 'data', 'temp', js_app)
19-
2016
ng_app = Settings.AppName.DEFAULT + 'NG'
21-
ng_source_project_dir = os.path.join(Settings.TEST_RUN_HOME, ng_app)
22-
ng_target_project_dir = os.path.join(Settings.TEST_RUN_HOME, 'data', 'temp', ng_app)
2317

2418
emu = None
2519
sim = None

0 commit comments

Comments
 (0)