Skip to content

Commit 062163e

Browse files
committed
Merge pull request #1016 from NativeScript/sd/karma
`test init` and `test android|ios` commands
2 parents a9685c5 + 2737cac commit 062163e

30 files changed

+590
-237
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
!/*.js
55
!bin/nativescript.js
66
!vendor/*.js
7+
!resources/**
78
*.js.map
89

910
coverage

.settings/tasks.json

Lines changed: 0 additions & 201 deletions
This file was deleted.

docs/man_pages/index.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ Command | Description
2929
[deploy `<Platform>`](project/testing/deploy.html) | Deploys the project to a connected physical or virtual device.
3030
[emulate `<Platform>`](project/testing/emulate.html) | Deploys the project in the native emulator for the selected target platform.
3131
[run `<Platform>`](project/testing/run.html) | Runs your project on a connected device or in the native emulator, if configured.
32-
[debug `<Platform>`](project/testing/debug.html) | Debugs your project on a connected device.
32+
[debug `<Platform>`](project/testing/debug.html) | Debugs your project on a connected physical or virtual device.
33+
[test init](project/testing/test-init.html) | Adds support for unit testing to your project.
34+
[test `<Platform>`](project/testing/test.html) | Runs the unit tests in your project on a connected physical or virtual device.
3335
[install](project/configuration/install.html) | Installs all platforms and dependencies described in the `package.json` file in the current directory.
3436
[plugin](lib-management/plugin.html) | Lets you manage the plugins for your project.
3537
[livesync](project/testing/livesync.html) | Synchronizes the latest changes in your project to devices.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
test android
2+
==========
3+
4+
Usage | Synopsis
5+
------|-------
6+
General | `$ tns test android [--watch] [--device <Device ID>] [--debug-brk]`
7+
8+
Runs the tests in your project on connected Android devices and emulators.
9+
10+
### Options
11+
* `--watch` - If set, when you save changes to the project, changes are automatically synchronized to the connected device and tests are re-run.
12+
* `--device` - Specifies the serial number or the index of the connected device on which to run the tests. To list all connected devices, grouped by platform, run `$ tns device`
13+
* `--debug-brk` - Run the tests under the debugger. The debugger will break just before your tests are executed, so you have a chance to place breakpoints.
14+
15+
### Attributes
16+
* `<Device ID>` is the device index or identifier as listed by `$ tns device`
17+
18+
<% if(isHtml) { %>
19+
### Related commands
20+
Command | Description
21+
--------|------------
22+
[test init](test-init.html) | Creates a test project in an existing NativeScript project
23+
<% } %>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
test init
2+
===========
3+
4+
Usage | Synopsis
5+
------|-------
6+
General | `$ tns test init [--framework <Framework>]`
7+
8+
Adds support for unit testing in an existing project.
9+
10+
### Options
11+
* `--framework <Framework>` - Specify the unit testing framework to install. Available frameworks are <%= formatListOfNames(constants.TESTING_FRAMEWORKS, 'and') %>.
12+
13+
<% if(isHtml) { %>
14+
### Related commands
15+
Command | Description
16+
--------|------------
17+
[test](test.html) | Run tests
18+
<% } %>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
test ios
2+
==========
3+
4+
Usage | Synopsis
5+
------|-------
6+
Run tests on all connected devices | `$ tns test ios [--watch] [--debug-brk]`
7+
Run tests on a selected device | `$ tns test ios --device <Device ID> [--watch] [--debug-brk]`
8+
Run tests in the iOS Simulator | `$ tns test ios --emulator [--watch] [--debug-brk]`
9+
10+
Runs the tests in your project on connected iOS devices or the iOS Simulator.
11+
12+
### Options
13+
* `--watch` - If set, when you save changes to the project, changes are automatically synchronized to the connected device and tests are re-ran.
14+
* `--device` - Specifies the serial number or the index of the connected device on which you want to run tests. To list all connected devices, grouped by platform, run `$ tns device`. You cannot set `--device` and `--emulator` simultaneously.
15+
* `--emulator` - Runs tests on the iOS Simulator. You cannot set `--device` and `--emulator` simultaneously.
16+
* `--debug-brk` - Run the tests under the debugger. The debugger will break just before your tests are executed, so you have a chance to place breakpoints.
17+
18+
<% if(isHtml) { %>
19+
### Related commands
20+
Command | Description
21+
--------|------------
22+
[test init](test-init.html) | Creates a test project in an existing NativeScript project
23+
<% } %>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
test
2+
===========
3+
4+
Usage | Synopsis
5+
------|-------
6+
General | `$ tns test <Platform>`
7+
8+
Run unit tests.
9+
10+
### Attributes
11+
`<Platform>` is the target mobile platform on which you want to run the tests. You can set the following target platforms:
12+
* `android` - Runs the tests in your project on connected Android devices.
13+
* `ios` - Runs the tests in your project on connected iOS devices.
14+
15+
16+
<% if(isHtml) { %>
17+
### Related commands
18+
Command | Description
19+
--------|------------
20+
[test init](test-init.html) | Creates a test project in an existing NativeScript project
21+
[test android](test-android.html) | Runs the tests in your project on Android devices.
22+
[test ios](test-ios.html) | Runs the tests in your project on iOS devices or the iOS Simulator.
23+
<% } %>

lib/bootstrap.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ $injector.requireCommand("deploy", "./commands/deploy");
4646
$injector.requireCommand("emulate|android", "./commands/emulate");
4747
$injector.requireCommand("emulate|ios", "./commands/emulate");
4848

49+
$injector.require("testExecutionService", "./services/test-execution-service");
50+
$injector.requireCommand("dev-test|android", "./commands/test");
51+
$injector.requireCommand("dev-test|ios", "./commands/test");
52+
$injector.requireCommand("test|android", "./commands/test");
53+
$injector.requireCommand("test|ios", "./commands/test");
54+
$injector.requireCommand("test|init", "./commands/test-init");
55+
4956
$injector.require("npm", "./node-package-manager");
5057
$injector.require("npmInstallationManager", "./npm-installation-manager");
5158
$injector.require("lockfile", "./lockfile");
@@ -74,3 +81,6 @@ $injector.requireCommand("init", "./commands/init");
7481
$injector.require("projectFilesManager", "./services/project-files-manager");
7582
$injector.requireCommand("livesync", "./commands/livesync");
7683
$injector.require("androidToolsInfo", "./android-tools-info");
84+
85+
$injector.require("iosUsbLiveSyncServiceLocator", "./services/usb-livesync-service");
86+
$injector.require("androidUsbLiveSyncServiceLocator", "./services/usb-livesync-service");

0 commit comments

Comments
 (0)