Skip to content

Commit 422dc2d

Browse files
authored
Add coverage for unit tests and functional tests (microsoft#3651)
* Add coverage for unit tests and functional tests * Fix anonymous methods * Fixed tests and linter issues * News entries * Remove redundant code
1 parent a3234ea commit 422dc2d

21 files changed

Lines changed: 1332 additions & 243 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ node_modules
66
**/.vscode/.ropeproject/**
77
**/testFiles/**/.cache/**
88
*.noseids
9+
.nyc_output
910
.vscode-test
1011
__pycache__
1112
npm-debug.log

.travis.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ matrix:
3939
- os: linux
4040
python: "3.7-dev"
4141
env: BUNDLE=true
42+
allow_failures:
43+
- os: linux
44+
python: "3.7-dev"
45+
env: FUNCTIONAL_TEST=true
4246
before_install: |
4347
if [ $TRAVIS_OS_NAME == "linux" ]; then
4448
export CXX="g++-4.9" CC="gcc-4.9" DISPLAY=:99.0;
@@ -65,7 +69,7 @@ install:
6569
script:
6670
- if [ $UNIT_TEST == "true" ]; then
6771
npm run cover:enable;
68-
npm run test:unittests;
72+
npm run test:unittests:cover;
6973
fi
7074
- if [ $DEBUGGER_TEST_RELEASE == "true" ]; then
7175
npm run cover:enable;
@@ -74,7 +78,7 @@ script:
7478
- npm run debugger-coverage
7579
- if [ $FUNCTIONAL_TEST == "true" ]; then
7680
python -m pip install --upgrade -r ./build/functional-test-requirements.txt;
77-
npm run test:functional;
81+
npm run test:functional:cover;
7882
fi
7983
- if [ $SINGLE_WORKSPACE_TEST == "true" ]; then
8084
npm run cover:enable;
@@ -107,3 +111,4 @@ script:
107111
npm run testSmoke;
108112
azure storage blob upload python*.vsix $AZURE_STORAGE_CONTAINER ms-python-$TRAVIS_BRANCH.vsix --account-name $AZURE_STORAGE_ACCOUNT --account-key $AZURE_STORAGE_ACCESS_KEY --quiet;
109113
fi
114+
- bash <(curl -s https://codecov.io/bash)

.vscode/launch.json

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,17 @@
119119
"name": "Unit Tests (without VS Code, *.unit.test.ts)",
120120
"type": "node",
121121
"request": "launch",
122-
"program": "${workspaceFolder}/out/test/unittests.js",
122+
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
123123
"stopOnEntry": false,
124124
"sourceMaps": true,
125125
"args": [
126+
"./out/test/**/*.unit.test.js",
127+
"--require=out/test/unittests.js",
128+
"--ui=tdd",
129+
"--recursive",
130+
"--colors",
126131
"timeout=300000",
127-
"grep="
132+
"--grep="
128133
],
129134
"outFiles": [
130135
"${workspaceFolder}/out/**/*.js"
@@ -135,12 +140,17 @@
135140
"name": "Functional Tests (without VS Code, *.functional.test.ts)",
136141
"type": "node",
137142
"request": "launch",
138-
"program": "${workspaceFolder}/out/test/functionalTests.js",
143+
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
139144
"stopOnEntry": false,
140145
"sourceMaps": true,
141146
"args": [
147+
"./out/test/**/*.functional.test.js",
148+
"--require=out/test/unittests.js",
149+
"--ui=tdd",
150+
"--recursive",
151+
"--colors",
142152
"timeout=300000",
143-
"grep="
153+
"--grep="
144154
],
145155
"outFiles": [
146156
"${workspaceFolder}/out/**/*.js"
@@ -166,4 +176,4 @@
166176
]
167177
}
168178
]
169-
}
179+
}

.vscode/settings.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"files.exclude": {
44
"out": true, // set this to true to hide the "out" folder with the compiled JS files
55
"**/*.pyc": true,
6+
".nyc_output": true,
67
"obj": true,
78
"bin": true,
89
"**/__pycache__": true,
@@ -13,7 +14,8 @@
1314
},
1415
"search.exclude": {
1516
"out": true, // set this to false to include "out" folder in search results
16-
"coverage": true
17+
"coverage": true,
18+
"languageServer*/**": true
1719
},
1820
"typescript.tsdk": "./node_modules/typescript/lib", // we want to use the TS server from our node_modules folder to control its version
1921
"tslint.enable": true,

.vscode/tasks.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
{
3939
"label": "Run Unit Tests",
4040
"type": "npm",
41-
"script": "test:unittests",
41+
"script": "test:unittests:cover",
4242
"group": {
4343
"kind": "test",
4444
"isDefault": true

.vscodeignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ webpack.datascience-ui.config.js
3333
.github/**
3434
.mocha-reporter/**
3535
.nvm/**
36+
.nyc_output
3637
.venv/**
3738
.vscode/**
3839
.vscode-test/**

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ You can also run them from the command-line (after compiling):
7777

7878
```shell
7979
npm run test:unittests # runs all unit tests
80-
npm run test:unittests grep='<NAME-OF-SUITE>'
80+
npm run test:unittests -- --grep='<NAME-OF-SUITE>'
8181
```
8282

8383
*To run only a specific test suite for unit tests:*
@@ -86,7 +86,7 @@ Alter the `launch.json` file in the `"Debug Unit Tests"` section by setting the
8686
```js
8787
"args": [
8888
"timeout=60000",
89-
"grep=[The suite name of your unit test file]"
89+
"--grep=[The suite name of your unit test file]"
9090
],
9191
```
9292
...this will only run the suite with the tests you care about during a test run (be sure to set the debugger to run the `Debug Unit Tests` launcher).

build/.mocha.functional.opts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
./out/test/**/*.functional.test.js
2+
--require out/test/unittests.js
3+
--exclude out/**/*.jsx
4+
--ui tdd
5+
--recursive
6+
--colors
7+
--timeout 120000

build/.mocha.unittests.opts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
./out/test/**/*.unit.test.js
2+
--require out/test/unittests.js
3+
--ui tdd
4+
--recursive
5+
--colors

build/.nycrc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"check-coverage": false,
3+
"per-file": true,
4+
"include": [
5+
"out/client/**/*.js"
6+
],
7+
"exclude": [
8+
"out/test/*.js",
9+
"out/**/*.jsx"
10+
],
11+
"reporter": [
12+
"lcov",
13+
"html"
14+
],
15+
"extension": [
16+
".js"
17+
],
18+
"cache": true,
19+
"all": true
20+
}

0 commit comments

Comments
 (0)