Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Teaching grover to report YUITest Code Coverage

  • Loading branch information...
commit 789b774eff796b820502ec2ca3a546c5cccd7280 1 parent ad114ac
@davglass authored
Showing with 37 additions and 0 deletions.
  1. +13 −0 bin/grover.js
  2. +17 −0 lib/index.js
  3. +7 −0 lib/wrapper.js
View
13 bin/grover.js
@@ -122,6 +122,19 @@ var done = function() {
res.jscoverage[i].miss = (res.jscoverage[i].lines - res.jscoverage[i].hit);
}
}
+ if (json.yuiTestCoverage) {
+ res.jscoverage = res.jscoverage || {};
+ for (var i in json.yuiTestCoverage) {
+ res.jscoverage[i] = res.jscoverage[i] || {};
+ res.jscoverage[i].hit = res.jscoverage[i].hit || 0;
+ res.jscoverage[i].lines = res.jscoverage[i].lines || 0;
+ res.jscoverage[i].miss = res.jscoverage[i].miss || 0;
+
+ res.jscoverage[i].hit += json.yuiTestCoverage[i].calledLines;
+ res.jscoverage[i].lines += json.yuiTestCoverage[i].coveredLines;
+ res.jscoverage[i].miss += (json.yuiTestCoverage[i].coveredLines - json.yuiTestCoverage[i].calledLines);
+ }
+ }
});
var END = (new Date()).getTime();
View
17 lib/index.js
@@ -81,6 +81,23 @@ module.exports = {
cov.percent = Math.floor((cov.hit / cov.lines) * 100);
}
+ if (json.yuiTestCoverage) {
+ showCoverage = true;
+ var coverage = json.yuiTestCoverage;
+ var cov = {
+ lines: 0,
+ hit: 0,
+ miss: 0,
+ percent: 0
+ };
+ for (var i in coverage) {
+ cov.lines = cov.lines + coverage[i].coveredLines;
+ cov.miss = cov.miss + (coverage[i].coveredLines - coverage[i].calledLines);
+ cov.hit = cov.hit + coverage[i].calledLines;
+ }
+ cov.percent = Math.floor((cov.hit / cov.lines) * 100);
+ }
+
var str = (json.failed ? bad.bold.red : good.bold.green) +
' ' + ('[' + json.name + ']:').bold[(json.failed ? 'red' : 'blue')] +
' Passed: ' + (json.passed ? (''+json.passed).green : json.passed) +
View
7 lib/wrapper.js
@@ -21,6 +21,13 @@ var injectGetYUITest = function() {
var YUITest = window.getYUITest();
if (YUITest) {
var json = YUITest.Runner.getResults(YUITest.Format.JSON);
+ var cover = YUITest.Runner.getCoverage();
+ if (json && cover) {
+ json = JSON.parse(json);
+ json.yuiTestCoverage = cover;
+ json = JSON.stringify(json);
+
+ }
if (window._$jscoverage && json) {
json = JSON.parse(json);
json.jscoverage = window._$jscoverage;
Please sign in to comment.
Something went wrong with that request. Please try again.