Support for generating code coverage reports

This commit is contained in:
Ian Gilman 2014-11-19 16:46:05 -08:00
parent 2508dd35f5
commit e465c24f2b
6 changed files with 114 additions and 12 deletions

2
.gitignore vendored
View File

@ -2,3 +2,5 @@
node_modules
build/
sftp-config.json
coverage/
temp/

View File

@ -1,3 +1,5 @@
/* global module */
module.exports = function(grunt) {
// ----------
@ -5,7 +7,7 @@ module.exports = function(grunt) {
grunt.loadNpmTasks("grunt-contrib-concat");
grunt.loadNpmTasks("grunt-contrib-jshint");
grunt.loadNpmTasks("grunt-contrib-uglify");
grunt.loadNpmTasks("grunt-contrib-qunit");
grunt.loadNpmTasks("grunt-qunit-istanbul");
grunt.loadNpmTasks("grunt-contrib-connect");
grunt.loadNpmTasks("grunt-contrib-watch");
grunt.loadNpmTasks("grunt-contrib-clean");
@ -72,6 +74,7 @@ module.exports = function(grunt) {
clean: {
build: ["build"],
package: [packageDir],
coverage: ["coverage"],
release: {
src: [releaseRoot],
options: {
@ -137,10 +140,26 @@ module.exports = function(grunt) {
}
},
qunit: {
normal: {
options: {
urls: [ "http://localhost:8000/test/test.html" ]
}
},
coverage: {
options: {
urls: [ "http://localhost:8000/test/coverage.html" ],
coverage: {
src: ['src/*.js'],
htmlReport: 'coverage/html/',
instrumentedFiles: 'temp/',
baseUrl: '.',
disposeCollector: true
}
}
},
all: {
options: {
timeout: 10000,
urls: [ "http://localhost:8000/test/test.html" ]
timeout: 10000
}
}
},
@ -248,7 +267,12 @@ module.exports = function(grunt) {
// ----------
// Test task.
// Builds and runs unit tests.
grunt.registerTask("test", ["build", "connect", "qunit"]);
grunt.registerTask("test", ["build", "connect", "qunit:normal"]);
// ----------
// Coverage task.
// Outputs unit test code coverage report.
grunt.registerTask("coverage", ["clean:coverage", "connect", "qunit:coverage"]);
// ----------
// Package task.

View File

@ -63,6 +63,12 @@ and open `http://localhost:8000/test/test.html` in your browser.
Another good page, if you want to interactively test out your changes, is `http://localhost:8000/test/demo/basic.html`.
You can also get a report of the tests' code coverage:
grunt coverage
The report shows up at `coverage/html/index.html` viewable in a browser.
### Contributing
OpenSeadragon is truly a community project; we welcome your involvement!

View File

@ -10,11 +10,11 @@
"grunt-git-describe": "^2.3.2",
"grunt-contrib-uglify": "^0.4.0",
"grunt-contrib-watch": "^0.6.1",
"grunt-contrib-qunit": "^0.5.1",
"grunt-contrib-jshint": "^0.10.0",
"grunt-contrib-compress": "^0.9.1",
"grunt-contrib-connect": "^0.7.1",
"qunitjs": "^1.14.0"
"qunitjs": "^1.14.0",
"grunt-qunit-istanbul": "^0.4.5"
},
"scripts": {
"test": "grunt test"

76
test/coverage.html Normal file
View File

@ -0,0 +1,76 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>OpenSeadragon QUnit</title>
<link rel="stylesheet" href="/node_modules/qunitjs/qunit/qunit.css">
<link rel="stylesheet" href="/test/lib/jquery-ui-1.10.2/css/smoothness/jquery-ui-1.10.2.min.css">
<link rel="stylesheet" href="/test/test.css">
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<script src="/node_modules/qunitjs/qunit/qunit.js"></script>
<script src="/test/lib/jquery-1.9.1.min.js"></script>
<script src="/test/lib/jquery-ui-1.10.2/js/jquery-ui-1.10.2.min.js"></script>
<script src="/test/lib/jquery.simulate.js"></script>
<!-- OpenSeadragon sources -->
<script src="/src/openseadragon.js"></script>
<script src="/src/fullscreen.js"></script>
<script src="/src/eventsource.js"></script>
<script src="/src/mousetracker.js"></script>
<script src="/src/control.js"></script>
<script src="/src/controldock.js"></script>
<script src="/src/viewer.js"></script>
<script src="/src/navigator.js"></script>
<script src="/src/strings.js"></script>
<script src="/src/point.js"></script>
<script src="/src/tilesource.js"></script>
<script src="/src/dzitilesource.js"></script>
<script src="/src/iiiftilesource.js"></script>
<script src="/src/osmtilesource.js"></script>
<script src="/src/tmstilesource.js"></script>
<script src="/src/legacytilesource.js"></script>
<script src="/src/tilesourcecollection.js"></script>
<script src="/src/button.js"></script>
<script src="/src/buttongroup.js"></script>
<script src="/src/rectangle.js"></script>
<script src="/src/referencestrip.js"></script>
<script src="/src/displayrectangle.js"></script>
<script src="/src/spring.js"></script>
<script src="/src/imageLoader.js"></script>
<script src="/src/tile.js"></script>
<script src="/src/overlay.js"></script>
<script src="/src/drawer.js"></script>
<script src="/src/viewport.js"></script>
<script src="/src/tiledimage.js"></script>
<script src="/src/tilecache.js"></script>
<script src="/src/world.js"></script>
<!-- Helpers -->
<script src="/test/legacy.mouse.shim.js"></script>
<script src="/test/test.js"></script>
<!-- Modules -->
<!-- Polyfill must be inserted first because it is testing functions
reassignments which could be done by other test. -->
<script src="/test/polyfills.js"></script>
<script src="/test/basic.js"></script>
<script src="/test/strings.js"></script>
<script src="/test/formats.js"></script>
<script src="/test/utils.js"></script>
<script src="/test/events.js"></script>
<script src="/test/units.js"></script>
<script src="/test/multi-image.js"></script>
<script src="/test/overlays.js"></script>
<script src="/test/controls.js"></script>
<script src="/test/viewport.js"></script>
<script src="/test/modules/world.js"></script>
<script src="/test/modules/drawer.js"></script>
<script src="/test/modules/tiledimage.js"></script>
<!-- The navigator tests are the slowest (for now; hopefully they can be sped up)
so we put them last. -->
<script src="/test/navigator.js"></script>
</body>
</html>

View File

@ -1,7 +1,5 @@
/* global QUnit, module, Util, $, console, test, asyncTest, start, ok, equal */
QUnit.config.autostart = false;
(function () {
var debug = false,
viewer,
@ -31,10 +29,6 @@ QUnit.config.autostart = false;
}
});
$(document).ready(function () {
start();
});
var resetTestVariables = function () {
if (viewer) {
viewer.close();