Skip to content

Commit 6aee241

Browse files
committed
init: nativescript tooling tests
Repository with tests for NativeScript tooling. WIP.
0 parents  commit 6aee241

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+4640
-0
lines changed

.gitignore

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
.DS_Store
2+
.idea
3+
package-lock.json
4+
nosetests.*
5+
node_modules
6+
TestApp
7+
out/*
8+
nativescript-sdk-*
9+
sample-Groceries
10+
master-detail*
11+
hello-world*
12+
tab-navigation*
13+
14+
# Byte-compiled / optimized / DLL files
15+
__pycache__/
16+
*.py[cod]
17+
*$py.class
18+
19+
# C extensions
20+
*.so
21+
22+
# Distribution / packaging
23+
.Python
24+
env/
25+
develop-eggs/
26+
dist/
27+
downloads/
28+
eggs/
29+
.eggs/
30+
lib/
31+
lib64/
32+
parts/
33+
sdist/
34+
var/
35+
wheels/
36+
*.egg-info/
37+
.installed.cfg
38+
*.egg
39+
40+
# PyInstaller
41+
# Usually these files are written by a python script from a template
42+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
43+
*.manifest
44+
*.spec
45+
46+
# Installer logs
47+
pip-log.txt
48+
pip-delete-this-directory.txt
49+
50+
# Unit test / coverage reports
51+
htmlcov/
52+
.tox/
53+
.coverage
54+
.coverage.*
55+
.cache
56+
nosetests.xml
57+
coverage.xml
58+
*,cover
59+
.hypothesis/
60+
61+
# Translations
62+
*.mo
63+
*.pot
64+
65+
# PyBuilder
66+
target/
67+
68+
# pyenv
69+
.python-version
70+
71+
# dotenv
72+
.env
73+
74+
# virtualenv
75+
.venv/
76+
venv/
77+
ENV/

HINTS.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Hints, Tips & Tricks
2+
3+
## PyCharm IDE
4+
5+
### Make `nose` default test runner
6+
7+
```
8+
Preference -> Tools -> Python integrated Tools - Choose Nosetests as Default test runner
9+
```
10+
11+
## Android Commandline Tools
12+
13+
### Emulator Quick Boot
14+
15+
Start emulator with no snapshot:
16+
```
17+
$ANDROID_HOME/emulator/emulator -avd Emulator-Api23-Default -wipe-data -no-snapshot-load -no-boot-anim
18+
```
19+
When stop emulator it will save its state and next boot with this command will be very fast:
20+
```
21+
$ANDROID_HOME/emulator/emulator -avd Emulator-Api23-Default -no-snapshot-save -no-boot-anim
22+
```
23+
24+
## Chrome
25+
26+
Chrome browser need to be in consistent state for debugger tests.
27+
You can achieve it by starting it with custom user profile:
28+
```
29+
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --user-data-dir=c:\temp-user-data
30+
```

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# NativeScript Tooling Tests
2+
3+
## About
4+
5+
Project with test for NativeScript tooling.
6+
7+
## Install Requirements
8+
9+
Install Python 2.*:
10+
```
11+
brew install python
12+
```
13+
14+
Update `pip` and install project requirements:
15+
```
16+
python -m pip install --upgrade pip
17+
pip install -r requirements.txt --user
18+
```
19+
20+
## Setup Environment
21+
22+
Please see [Setup](SETUP.md) document.
23+
24+
## Run Tests
25+
26+
```
27+
nosetests -v -s --nologcapture --with-xunit --xunit-file out/nosetests.xml --with-html --html-report-template=core/report/template.html --html-file=out/nosetests.html --all-modules tests/cli/build/
28+
```
29+
30+
## Hints, Tips and Tricks
31+
32+
Please see [Hints, Tips and Tricks](HINTS.md) document.

SETUP.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Setup
2+
3+
## Manual Setup
4+
5+
### macOS Setup
6+
7+
System Preferences -> Security & Privacy -> Privacy -> Accessibility ->
8+
- Add Terminal to list of apps allowed to control your computer (to be able to run tests via Terminal)
9+
- Add PyCharm to list of apps allowed to control your computer (to be able to run tests via IDE)
10+
11+
## Environment Variables
12+
In order to run tests some environment variables should be set.
13+
14+
### Building Android and iOS apps
15+
16+
Android release builds require:
17+
18+
ANDROID_KEYSTORE_PATH - Path to the keystore file
19+
20+
ANDROID_KEYSTORE_PASS - Password for the keystore file
21+
22+
ANDROID_KEYSTORE_ALIAS
23+
24+
ANDROID_KEYSTORE_ALIAS_PASS
25+
26+
iOS release builds for device require:
27+
28+
DEVELOPMENT_TEAM - Development team
29+
30+
PROVISIONING - Development provisioning profile
31+
32+
DISTRIBUTION_PROVISIONING - Distribution provisioning profile
33+
34+
### Other
35+
36+
Git settings (optional)
37+
38+
SSH_CLONE - True or False (if not set tests will default to False).
39+
40+
Skip `tns doctor` (optional)
41+
42+
NS_SKIP_ENV_CHECK - If set (no matter of the value) doctor is not executed.

core/__init__.py

Whitespace-only changes.

core/base_test/__init__.py

Whitespace-only changes.

core/base_test/base_test.py

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
import inspect
2+
import os
3+
import unittest
4+
5+
from core.base_test.run_context import TestContext
6+
from core.enums.os_type import OSType
7+
from core.log.log import Log
8+
from core.settings import Settings
9+
from core.utils.device.device_manager import DeviceManager
10+
from core.utils.file_utils import Folder
11+
from core.utils.gradle import Gradle
12+
from core.utils.process import Process
13+
from core.utils.xcode import Xcode
14+
from products.nativescript.tns import Tns
15+
16+
17+
class BaseTest(unittest.TestCase):
18+
@classmethod
19+
def setUpClass(cls):
20+
# Get class name and log
21+
caller_class = inspect.stack()[1][0].f_locals['cls'].__name__
22+
Log.test_class_start(class_name=caller_class)
23+
24+
# Kill processes
25+
Tns.kill()
26+
Gradle.kill()
27+
BaseTest.kill_emulators()
28+
29+
# Ensure log folders are create
30+
Folder.create(Settings.TEST_OUT_HOME)
31+
Folder.create(Settings.TEST_OUT_LOGS)
32+
Folder.create(Settings.TEST_OUT_IMAGES)
33+
34+
# Set default simulator based on Xcode version
35+
if Settings.HOST_OS == OSType.OSX:
36+
if Xcode.get_version() < 10:
37+
Settings.Simulators.DEFAULT = Settings.Simulators.SIM_IOS11
38+
else:
39+
Settings.Simulators.DEFAULT = Settings.Simulators.SIM_IOS12
40+
41+
def setUp(self):
42+
TestContext.TEST_NAME = self._testMethodName
43+
Log.test_start(test_name=TestContext.TEST_NAME)
44+
Tns.kill()
45+
Gradle.kill()
46+
47+
def tearDown(self):
48+
Tns.kill()
49+
50+
for process in TestContext.STARTED_PROCESSES:
51+
Log.info("Kill Process: " + os.linesep + process.commandline)
52+
Process.kill_pid(process.pid)
53+
54+
# Analise test result
55+
result = self._resultForDoCleanups
56+
outcome = 'FAILED'
57+
if result.errors == [] and result.failures == []:
58+
outcome = 'PASSED'
59+
60+
Log.test_end(test_name=TestContext.TEST_NAME, outcome=outcome)
61+
62+
@classmethod
63+
def tearDownClass(cls):
64+
"""
65+
Logic executed after all core_tests in class.
66+
"""
67+
Tns.kill()
68+
BaseTest.kill_emulators()
69+
for process in TestContext.STARTED_PROCESSES:
70+
Log.info("Kill Process: " + os.linesep + process.commandline)
71+
Process.kill_pid(process.pid)
72+
Log.test_class_end(class_name=cls.__name__)
73+
74+
@staticmethod
75+
def kill_emulators():
76+
DeviceManager.Emulator.stop()
77+
if Settings.HOST_OS is OSType.OSX:
78+
DeviceManager.Simulator.stop()
79+
80+
81+
if __name__ == '__main__':
82+
unittest.main()

core/base_test/run_context.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class TestContext(object):
2+
STARTED_PROCESSES = []
3+
TEST_NAME = None
4+
TEST_APP_NAME = None
5+
EMU_ID = None
6+
SIM_ID = None
7+
ANDROID_ID = None
8+
IOS_IS = None

core/enums/__init__.py

Whitespace-only changes.

core/enums/app_type.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"""
2+
Application type enum.
3+
"""
4+
from aenum import Enum
5+
6+
7+
class AppType(Enum):
8+
_init_ = 'value string'
9+
10+
JS = 1, 'js'
11+
TS = 2, 'ts'
12+
NG = 3, 'ng'
13+
VUE = 4, 'vue'
14+
SHARED_NG = 5, 'shared_ng'
15+
16+
def __str__(self):
17+
return self.string

core/enums/device_type.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
Device type enum.
3+
"""
4+
from aenum import Enum
5+
6+
7+
class DeviceType(Enum):
8+
_init_ = 'value string'
9+
10+
EMU = 1, 'emulator'
11+
SIM = 2, 'simulator'
12+
ANDROID = 3, 'android device'
13+
IOS = 3, 'ios device'
14+
15+
def __str__(self):
16+
return self.string

core/enums/log_level.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"""
2+
Device type enum.
3+
"""
4+
from aenum import Enum
5+
6+
7+
class LogLevel(Enum):
8+
_init_ = 'value string'
9+
10+
TRACE = 1, 'trace'
11+
DEBUG = 2, 'debug'
12+
INFO = 3, 'info'
13+
WARN = 4, 'warn'
14+
ERROR = 5, 'error'
15+
16+
def __str__(self):
17+
return self.string

core/enums/os_type.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"""
2+
Host OS enum.
3+
"""
4+
from aenum import Enum
5+
6+
7+
class OSType(Enum):
8+
_init_ = 'value string'
9+
10+
WINDOWS = 1, 'Windows'
11+
LINUX = 2, 'Linux'
12+
OSX = 3, 'macOS'
13+
14+
def __str__(self):
15+
return self.string

core/enums/platform_type.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"""
2+
{N} Platform Type.
3+
"""
4+
from aenum import Enum
5+
6+
7+
class Platform(Enum):
8+
_init_ = 'value string'
9+
10+
ANDROID = 1, 'android'
11+
IOS = 2, 'ios'
12+
NONE = 3, ''
13+
14+
def __str__(self):
15+
return self.string

core/log/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)