Skip to content

Commit e0e010a

Browse files
author
Omar Shehata
authored
Merge pull request #8115 from AnalyticalGraphicsInc/coverage
Replace jscoverage with karma-coverage
2 parents a1565d9 + c243d42 commit e0e010a

File tree

115 files changed

+81
-12506
lines changed

Some content is hidden

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

115 files changed

+81
-12506
lines changed

.eslintignore

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ Apps/HelloWorld.html
22
Apps/Sandcastle/ThirdParty/**
33
Build/**
44
Documentation/**
5-
Instrumented/**
65
Source/Shaders/**
76
Source/ThirdParty/**
87
Source/Workers/cesiumWorkerBootstrapper.js

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/.metadata
22
/Build
3-
/Instrumented
43
/Cesium-*.zip
54
/cesium-*.tgz
65
.DS_Store

.npmignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
/.travis.yml
1212
/.vscode
1313
/Apps
14+
/Build/Coverage
1415
/Build/minifyShaders.state
1516
/Build/Stubs
1617
/Build/Documentation
@@ -20,7 +21,6 @@
2021
/gulpfile.js
2122
/index.html
2223
/index.release.html
23-
/Instrumented
2424
/launches
2525
/server.js
2626
/Source/copyrightHeader.js

.travis.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ script:
1616
- npm --silent run eslint
1717

1818
- npm --silent run build
19-
- npm --silent run test -- --browsers FirefoxHeadless --webgl-stub --failTaskOnError --suppressPassed
19+
- npm --silent run coverage -- --browsers FirefoxHeadless --webgl-stub --failTaskOnError --suppressPassed
2020

21-
- npm --silent run clean
2221
- travis_wait 20 npm --silent run makeZipFile -- --concurrency 1
2322
- npm pack &> /dev/null
2423

.vscode/settings.json

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
},
1414
"search.exclude": {
1515
"Build": true,
16-
"Instrumented": true,
1716
"node_modules": true,
1817
"Source/Shaders/**/*.js": true
1918
},

Documentation/Contributors/BuildGuide/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@ Here's the full set of scripts and what they do.
103103
* `release` - A full release build that creates a shippable product, including building apps and generating documentation.
104104
* `makeZipFile` - Builds a zip file containing all release files. This includes the source tree (suitable for use from an AMD-aware application), plus the combined and minified Cesium.js files, the generated documentation, the test suite, and the example applications (in both built and source form).
105105
* **Utility scripts** -- code coverage, static code analysis, and other utilities
106-
* `instrumentForCoverage` - Runs [JSCoverage](http://siliconforks.com/jscoverage/) on the source tree to allow running tests with coverage information. Use the link in index.html. Currently Windows only.
106+
* `coverage` - Runs coverage and opens the default browser with the results.
107107
* `eslint` - Runs [ESLint](http://eslint.org/), a static code analysis tool, on the entire source tree.
108-
* `eslint-watch` - A never-ending task that watches your file system for changes to Cesium and runs ESLint on any changed source files.
108+
* `eslint-watch` - A never-ending task that watches your file system for changes to Cesium and runs ESLint on any changed source files.
109109
* `clean` - Removes all generated build artifacts.
110110
* `cloc` - Runs [CLOC](https://github.com/AlDanial/cloc) to count the lines of code on the Source and Specs directories. This requires [Perl](http://www.perl.org/) to execute.
111111
* `sortRequires` - Alphabetically sorts the list of required modules in every `js` file. It also makes sure that the top of every source file uses the same formatting.
-38.5 KB
Loading
-75 KB
Loading

Documentation/Contributors/TestingGuide/README.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ All new code should have 100% code coverage and should pass all tests. Always r
1414
* [Run Only WebGL Tests](#run-only-webgl-tests)
1515
* [Run Only Non-WebGL Tests](#run-only-non-webgl-tests)
1616
* [Run All Tests against Combined File (Run All Tests against Combined File with Debug Code Removed)]()
17-
* [Run All Tests with Code Coverage (Build 'instrumentForCoverage' First)](#run-all-tests-against-combined-file-run-all-tests-against-combined-file-with-debug-code-removed)
17+
* [Run All Tests with Coverage](#run-all-tests-against-combined-file-run-all-tests-against-combined-file-with-debug-code-removed)
1818
* [Running Tests on the Command Line with Karma](#running-tests-on-the-command-line-with-karma)
1919
* [Testing Previous Versions of CesiumJS](#testing-previous-versions-of-cesium)
2020
* [`testfailure` Label for Issues](#testfailure-label-for-issues)
@@ -108,25 +108,25 @@ The **Run All Tests against Combined File with Debug Code Removed** is the same
108108

109109
See the [Build Guide](https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Documentation/Contributors/BuildGuide/README.md#build-scripts) for all the CesiumJS build options.
110110

111-
### Run All Tests with Code Coverage (Build 'instrumentForCoverage' First)
111+
## Run Coverage
112112

113-
[JSCoverage](http://siliconforks.com/jscoverage/) is used for code coverage. It is especially important to have outstanding code coverage since JavaScript doesn't have a compiler and linker to catch early errors.
113+
We use [istanbul](https://istanbul.js.org/) via [karma-coverage](https://github.com/karma-runner/karma-coverage) to generate code coverage reports. It is especially important to have outstanding code coverage since JavaScript doesn't have a compiler and linker to catch early errors.
114114

115-
To run code coverage, first create a build of CesiumJS that is instrumented for coverage by running `npm run instrumentForCoverage`. Currently, this is Windows only.
115+
To generate a coverage report, run: `npm run coverage`. This will place a report inside of the `Build/Coverage/<browser>` folder and open your default browser with the result.
116116

117-
Then use this test option to run the tests with code coverage. Click on the `Summary` tab to see the total code coverage and coverage for each individual source file.
117+
You'll see a source tree that matches Cesium's own code layout. Each directory shows aggregated results for all files it contains.
118118

119119
![](4.jpg)
120120

121-
Click on a file to see line-by-line coverage for just that file. For example, here is `AssociativeArray`:
121+
Click on a directory to see results for each file in that directory. Click on a specific file to see line-by-line coverage for just that file. For example, here is `Core/AssociativeArray`:
122122

123123
![](5.jpg)
124124

125-
In the left margin, green indicates a line that was executed, and red indicates a line that was not. Many lines, such as comments and semicolons, are not colored since they are not executable.
125+
In the left margin, green indicates how many times a line was executed. Many lines, such as comments and semicolons, are not colored since they are not executable.
126126

127127
For the `contains` function above
128128
* `AssociativeArray.prototype.contains = function(key) {` is executed once when CesiumJS is loaded to assign the `contains` function to the `AssociativeArray`'s prototype.
129-
* The `if` statement and return statement are executed 3,425 times.
129+
* The `if` statement and return statement are executed 8,022 times.
130130
* The `throw` statement is not executed, which indicates that test coverage should be improved here. We strive to test _all_ error conditions.
131131

132132
When writing tests, do not confuse 100% code coverage with 100% tested. For example, it is possible to have 100% code coverage without having any expectations. Also consider the following code:

0 commit comments

Comments
 (0)