-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathUnitTests_Tests.py
89 lines (65 loc) · 3.6 KB
/
UnitTests_Tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import os.path
from core.base_class.BaseClass import BaseClass
from core.osutils.command import run
from core.osutils.file import File
from core.osutils.folder import Folder
from core.tns.tns import Tns
class UnitTests(BaseClass):
@classmethod
def setUpClass(cls):
logfile = os.path.join("out", cls.__name__ + ".txt")
BaseClass.setUpClass(logfile)
def setUp(self):
BaseClass.setUp(self)
Folder.cleanup(self.app_name)
def tearDown(self):
BaseClass.tearDown(self)
Folder.cleanup(self.app_name)
@classmethod
def tearDownClass(cls):
pass
def test_101_test_init_jasmine(self):
Tns.create_app(app_name=self.app_name)
output = Tns.run_tns_command("test init", attributes={"--framework": "jasmine",
"--path ": self.app_name})
assert "Successfully installed plugin nativescript-unit-test-runner." in output
assert "Example test file created in app/tests/" in output
assert "Run your tests using the \"$ tns test <platform>\" command." in output
output = run("cat " + self.app_name + "/package.json")
assert "karma-jasmine" in output
# assert "jasmine-core" in output //no such package is being installed (we install karma, karma-jasmine, karma-nativescript-launcher none of which install jasmine-core)
output = run("cat " + self.app_name + "/karma.conf.js")
assert "frameworks: ['jasmine']" in output
output = run("cat " + self.app_name + "/app/tests/example.js")
assert "Jasmine test" in output
assert File.exists(self.app_name + "/hooks/after-prepare/nativescript-unit-test-runner.js")
def test_201_test_init_mocha(self):
Tns.create_app(app_name=self.app_name)
output = Tns.run_tns_command("test init", attributes={"--framework": "mocha",
"--path": self.app_name})
assert "Successfully installed plugin nativescript-unit-test-runner." in output
assert "Example test file created in app/tests/" in output
assert "Run your tests using the \"$ tns test <platform>\" command." in output
output = run("cat " + self.app_name + "/package.json")
assert "karma-chai" in output
assert "karma-mocha" in output
output = run("cat " + self.app_name + "/karma.conf.js")
assert "frameworks: ['mocha', 'chai']" in output
output = run("cat " + self.app_name + "/app/tests/example.js")
assert "Mocha test" in output
assert File.exists(self.app_name + "/hooks/after-prepare/nativescript-unit-test-runner.js")
def test_301_test_init_qunit(self):
Tns.create_app(app_name=self.app_name)
output = Tns.run_tns_command("test init", attributes={"--framework": "qunit",
"--path": self.app_name})
assert "Successfully installed plugin nativescript-unit-test-runner." in output
assert "Example test file created in app/tests/" in output
assert "Run your tests using the \"$ tns test <platform>\" command." in output
output = run("cat " + self.app_name + "/package.json")
assert "karma-qunit" in output
assert "qunitjs" in output
output = run("cat " + self.app_name + "/karma.conf.js")
assert "frameworks: ['qunit']" in output
output = run("cat " + self.app_name + "/app/tests/example.js")
assert "QUnit test" in output
assert File.exists(self.app_name + "/hooks/after-prepare/nativescript-unit-test-runner.js")